Black Lives Matter. Please consider donating to Black Girls Code today.

Client socket timeout when writing pdf image

Hi there, I’m having problems creating a PDF from a BarPolar figure object!

My Code

import plotly.graph_objects as go

def create_polar_bar(r: list, theta: list, title: str):
    fig = go.Figure(go.Barpolar(

        # layout

        showlegend = True,

    fig.write_image(file=f"{title}.pdf", format="pdf")
    # fig.write_html(file=f"{title}.html")

theta = ['File', 'DNS', 'Internet', 'ICMP', 'Registry', 'Process', 'Mutex', 'Module', 'System', 'Service', 'Memory', 'Thread', 'Keyboard', 'Driver', 'User', 'Share', 'Debug', 'Kernel Debug', 'Environment', 'Ini', 'URL', 'Window']
r = [67.0, 0.0, 0.0, 0.0, 19.0, 7.0, 0.0, 203.0, 19.0, 6.0, 4.0, 4.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 10.0, 0.0, 0.0, 2.0]
create_polar_bar(r, theta, "Visualization")

When I use the function write_html the code works perfectly. But the code throws some exceptions when I’m trying to save it as static PDF image.


Traceback (most recent call last):
  File "C:\Users\winklerrr\AppData\Roaming\Python\Python37\site-packages\plotly\io\", line 1559, in to_image
    figure=fig_dict, format=format, scale=scale, width=width, height=height
  File "C:\Users\winklerrr\AppData\Roaming\Python\Python37\site-packages\", line 49, in wrapped_f
    return Retrying(*dargs, **dkw).call(f, *args, **kw)
  File "C:\Users\winklerrr\AppData\Roaming\Python\Python37\site-packages\", line 212, in call
    raise attempt.get()
  File "C:\Users\winklerrr\AppData\Roaming\Python\Python37\site-packages\", line 247, in get
    six.reraise(self.value[0], self.value[1], self.value[2])
  File "C:\Users\winklerrr\AppData\Roaming\Python\Python37\site-packages\", line 693, in reraise
    raise value
  File "C:\Users\winklerrr\AppData\Roaming\Python\Python37\site-packages\", line 200, in call
    attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
  File "C:\Users\winklerrr\AppData\Roaming\Python\Python37\site-packages\plotly\io\", line 1474, in request_image_with_retrying
    raise OSError("522: client socket timeout")
OSError: 522: client socket timeout

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File ".\", line 43, in <module>
    create_polar_bar(r, theta, "Visualization")
  File "...\", line 21, in create_polar_bar
    fig.write_image(file=f"{title}.pdf", format="pdf")
  File "C:\Users\winklerrr\AppData\Roaming\Python\Python37\site-packages\plotly\", line 2824, in write_image
    return pio.write_image(self, *args, **kwargs)
  File "C:\Users\winklerrr\AppData\Roaming\Python\Python37\site-packages\plotly\io\", line 1767, in write_image
    fig, format=format, scale=scale, width=width, height=height, validate=validate
  File "C:\Users\winklerrr\AppData\Roaming\Python\Python37\site-packages\plotly\io\", line 1591, in to_image
For some reason was unable to communicate with the
local orca server process, even though the server process seems to be running.

Please review the process and connection information below:

orca status
    state: running
    executable: C:\Users\winklerrr\AppData\Roaming\npm\orca.CMD
    version: 1.2.1
    port: 50421
    pid: 864
    command: ['C:\\Users\\winklerrr\\AppData\\Roaming\\npm\\orca.CMD', 'serve', '-p', '50421', '--plotly', 'C:\\Users\\winklerrr\\AppData\\Roaming\\Python\\Python37\\site-packages\\plotly\\package_data\\plotly.min.js', '--graph-only', '--mathjax', '']

My Setup

I’m working under Windows 10 with Python 3.7.
I installed Orca 1.2.1 with npm.

What I already tried

When I try to run the following command manually (with the --debug flag at the end) nothing happens and no output is generated at all:

C:\Users\winklerrr\AppData\Roaming\npm\orca.CMD serve -p 50221 --plotly C:\Users\winklerrr\AppData\Roaming\Python\Python37\site-packages\plotly\package_data\plotly.min.js --graph-only --mathjax --debug

Hi @winklerrr welcome to the forum! Other users have suggested solutions in, maybe one of them can help? (for example the removal of temporary files mentioned at the end).

Hi @Emmanuelle, thanks for your answer.

In issue 182, they explain that the Orca service successfully ran before and that the problem occurs only sometimes. For me that’s not the case: it crashes since the first run. I was not able to create a PDF even once.

The last comment in that thread talks about permission issues caused by executions of different users. I just have one user on my system.

Additional information

Maybe it has something to do with my work environment?

  • I’m working in VS code
  • with a venv set up for Windows
  • I tried installing Orca before with Anaconda (but that didn’t work at all)

Possible Solutions

Is there a way how I could check if my Orca installation was all good? Maybe a command that I could run where an expected output would happen?

Or could you tell me what the exact steps are to set up a fresh installation of and orca (with all the Python packages I need and settings I need to configure?)

OK, thanks for the info. Yes, a fresh install might be better. In theory installing orca with conda is easier, what didn’t work? I would suggest to remove orca using npm, also plotly using either conda or pip, and then try to install both orca and plotly with conda as described on

Orca not available for Anaconda 32 Bit?

Okay, so let me summarize my progress here for further readers and better support from your side. What I did until now:

  1. Uninstalled all Python installations (and remaining Python data in %APPDATA%/Python)
  2. Uninstalled Anaconda
  3. Uninstalled Node.js (npm and Orca Electron App)
  4. Cleaned the PATH variable
  5. Restarted the machine

Then I tried to freshly install Anaconda:

  1. Downloaded the 32Bit version of Anaconda here:
  2. Installed Anaconda without setting the PATH variable during installation
  3. Started the Anaconda Navigator to see if the installation was successful
  4. Started the Anaconda Prompt and checked the installation paths of conda and python with:
$ where conda
$ where python
  1. Added all paths of the output to the PATH variable
  2. Started cmd to check if everything works as expected by typing: python --version
  3. Created a python file with the code from my first post and executed it with:

Then this error message showed up:

The orca executable is required to export figures as static images,
but it could not be found on the system path.

If you haven't installed orca yet, you can do so using conda as follows:

    $ conda install -c plotly plotly-orca

So I ran the command conda install -c plotly plotly-orca to install Orca and this was the result:

Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

  - plotly-orca

I then navigated to and checked manually for the Orca package and I was able to find it here:

But there it looks like the package is only available for 64bit Windows!
Is that correct?

So I think, I will go through that process again and install Anaconda in the 64Bit version.
(Would have been nice when that limitation would have been mentioned in the Orca README…)

Switching to Anaconda 3 for 64Bit

So I uninstalled Anaconda 3 for 32 Bit and cleaned the PATH variable.
Then I restarted my machine.

Problems with Anaconda 3 64 Bit itself

After installing Anaconda 3 with its 64Bit installer, I’m not even able to start the Anaconda Navigator.
There is just a cmd popping up, which then immediately gets closed again.
So it seems like there must be something wrong with Anaconda 3 in its 64Bit version?!

SSL Problems installing further conda packages

After adding the Anaconda folder back to my PATH variable, I was able to execute python --version and conda --version from a cmd. Seems to work.

So I tried running my again with the new Anaconda version.
Again it tells me, that conda isn’t installed and show me the install command.
After running the install command I now get this error message:

$ conda install -c plotly plotly-orca
Collecting package metadata (current_repodata.json): failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <>
Elapsed: -

An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
SSLError(MaxRetryError('HTTPSConnectionPool(host=\'\', port=443): Max retries exceeded with url: /plotly/win-64/current_repodata.json (Caused by SSLError("Can\'t connect to HTTPS URL because the SSL module is not available."))'))


With the instructions from here: I was able to get Anaconda 64Bit running. The download of Orca now worked and the creation of the PDF was successful!