Static image export socket timeout

Hi,

I am having trouble exporting figures in plotly 3.2/3.3. All the required packages load correctly and I can create figures both online and offline. Orca works in some circumstances:

from subprocess import call
import json
import plotly

fig = {"data": [{"y": [1,2,1]}]}
call(['orca', 'graph', json.dumps(fig, cls=plotly.utils.PlotlyJSONEncoder)])

This does export fig.png correctly. Now with another example:

import plotly.graph_objs as go
import plotly.io as pio
import plotly
import numpy as np

N = 100
x = np.random.rand(N)
y = np.random.rand(N)
colors = np.random.rand(N)
sz = np.random.rand(N)*30

fig = go.Figure()
fig.add_scatter(x=x,
                y=y,
                mode='markers',
                marker={'size': sz,
                        'color': colors,
                        'opacity': 0.6,
                        'colorscale': 'Viridis'
                       });

pio.write_image(fig, "test.png")

After maybe 30 seconds or so, I receive:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "//anaconda/envs/pythonmap/lib/python2.7/site-packages/plotly/io/_orca.py", line 1486, in write_image
validate=validate)
File "//anaconda/envs/pythonmap/lib/python2.7/site-packages/plotly/io/_orca.py", line 1391, in to_image
raise ValueError(err_message)
ValueError: 
The image request was rejected by the orca conversion utility
with the following error:
522: client socket timeout

Can someone please help me correct this error? Thanks!

I do not have a solution for Mac, but this works on Centos 7 (I also had 2.7 errors on Centos as well):

conda create -n py37 python=3.7 anaconda
source activate py37
pip install --upgrade pip
pip install plotly
conda install -c plotly plotly-orca psutil
conda install geopandas
conda install pyshp

Small notes:

  • This installs pyshp-1.2.12 instead of 1.2.10.
  • geopandas downgrades hdf5 from 1.10.2 to 1.8.18.

I am not receiving any errors but will report back if I do.

Hi @will3324,

Hmm, this isn’t an error I’ve seen on macOS before. Do you have any kind of firewall or extra security software enabled?

-Jon

No, I can try a fresh 3.7 install on my mac and will see if I receive the same error.

Hi All,
have you been able to solve this issue ?

I’m on windows with a firewall ( within a company that’s why i need full offline)

when using
!orca graph “{ “data”: [{“y”: [1,2,60]}] }” -o fig.png
on a command window it works though.

Could there be a way around this problem by using the command window method within a .py file ?

Thanks so much !


ValueError Traceback (most recent call last)
in
1 import plotly.io as pio
2 pio.orca.config
----> 3 pio.write_image(fig, ‘images/fig1.png’)

C:\ProgramData\Anaconda3\lib\site-packages\plotly\io_orca.py in write_image(fig, file, format, scale, width, height, validate)
1703 # Do this first so we don’t create a file if image conversion fails
1704 img_data = to_image(
-> 1705 fig, format=format, scale=scale, width=width, height=height, validate=validate
1706 )
1707

C:\ProgramData\Anaconda3\lib\site-packages\plotly\io_orca.py in to_image(fig, format, width, height, scale, validate)
1480 # Make sure orca sever is running
1481 # -------------------------------
-> 1482 ensure_server()
1483
1484 # Handle defaults

C:\ProgramData\Anaconda3\lib\site-packages\plotly\io_orca.py in ensure_server()
1342 # Validate orca executable
1343 if status.state == “unvalidated”:
-> 1344 validate_executable()
1345
1346 # Acquire lock to make sure that we keep the properties of orca_state

C:\ProgramData\Anaconda3\lib\site-packages\plotly\io_orca.py in validate_executable()
1041 executable=config.executable,
1042 formatted_path=formatted_path,
-> 1043 instructions=install_location_instructions,
1044 )
1045 )

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

Searched for executable ‘C:\ProgramData\Anaconda3\orca_app’ on the following path:
C:\ProgramData\Anaconda3
C:\ProgramData\Anaconda3\Library\mingw-w64\bin
C:\ProgramData\Anaconda3\Library\usr\bin
C:\ProgramData\Anaconda3\Library\bin
C:\ProgramData\Anaconda3\Scripts
C:\ProgramData\Anaconda3\bin
C:\ProgramData\Anaconda3\condabin
C:\ProgramData\Anaconda3
C:\ProgramData\Anaconda3\Library\mingw-w64\bin
C:\ProgramData\Anaconda3\Library\usr\bin
C:\ProgramData\Anaconda3\Library\bin
C:\ProgramData\Anaconda3\Scripts
C:\windows\System32
C:\windows
C:\windows\System32\Wbem
C:\ProgramData\Oracle\Java\javapath
C:\progra~1\sybase\DBISQL\bin
C:\progra~1\sybase\DataAccess64\ADONET\dll
C:\progra~1\sybase\DataAccess\ADONET\dll
C:\progra~1\sybase\DataAccess64\ODBC\dll
C:\progra~1\sybase\DataAccess\ODBC\dll
C:\progra~1\sybase\DataAccess64\OLEDB\dll
C:\progra~1\sybase\DataAccess\OLEDB\dll
C:\progra~1\sybase\OCS-15_0\lib3p64
C:\progra~1\sybase\OCS-15_0\lib3p
C:\progra~1\sybase\OCS-15_0\dll
C:\progra~1\sybase\OCS-15_0\bin
C:\windows\System32\WindowsPowerShell\v1.0
c:\programdata\IPGM\OraPGM64\Oracle\Client11gR2\bin
c:\programdata\IPGM\OraPGM32\Oracle\Client11gR2\bin
C:\PROGRA~1\IBM\SQLLIB\BIN
C:\PROGRA~1\IBM\SQLLIB\FUNCTION
C:\Program Files (x86)\SafeCom\SafeComPrintClient
C:\Program Files (x86)\Enterprise Vault\EVClient
C:\Program Files\MiKTeX 2.9\miktex\bin\x64
C:\windows\System32\WindowsPowerShell\v1.0
C:\Users\P885880\ml
C:\Users\P885880\AppData\Local\Continuum\anaconda3
C:\Users\P885880\AppData\Local\Temp
C:\Program Files (x86)\Enterprise Vault\EVClient
C:\Program Files\nodejs
C:\ProgramData\Anaconda3\orca_app
C:\Users\P885880\AppData\Local\Programs\Python\Python37-32\Scripts
C:\Users\P885880\AppData\Local\Programs\Python\Python37-32
C:\Program Files (x86)\Bloomberg\DAPI
C:\Program Files (x86)\Bloomberg\DAPI\DDE
C:\Program Files (x86)\Mozilla Firefox
C:\windows\System32
C:\windows
C:\windows\System32\Wbem
C:\progra~1\sybase\DBISQL\bin
C:\progra~1\sybase\DataAccess64\ADONET\dll
C:\progra~1\sybase\DataAccess\ADONET\dll
C:\progra~1\sybase\DataAccess64\ODBC\dll
C:\progra~1\sybase\DataAccess\ODBC\dll
C:\progra~1\sybase\DataAccess64\OLEDB\dll
C:\progra~1\sybase\DataAccess\OLEDB\dll
C:\progra~1\sybase\OCS-15_0\lib3p64
C:\progra~1\sybase\OCS-15_0\lib3p
C:\progra~1\sybase\OCS-15_0\dll
C:\progra~1\sybase\OCS-15_0\bin
C:\windows\System32\WindowsPowerShell\v1.0
c:\programdata\IPGM\OraPGM64\Oracle\Client11gR2\bin
c:\programdata\IPGM\OraPGM32\Oracle\Client11gR2\bin
C:\PROGRA~1\IBM\SQLLIB\BIN
C:\PROGRA~1\IBM\SQLLIB\FUNCTION
C:\Program Files (x86)\SafeCom\SafeComPrintClient
C:\Program Files (x86)\Enterprise Vault\EVClient
\U13pfl01.hd00.unicreditgroup.eu\p885880$\P885880.HOME\Redirected_Profile\AppData\npm
C:\ProgramData\Anaconda3\orca_app
C:\ProgramData\Anaconda3
C:\ProgramData\Anaconda3\scripts
C:\ProgramData\Anaconda3\orca_app

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

$ conda install -c plotly plotly-orca

Alternatively, see other installation methods in the orca project README at
https://github.com/plotly/orca.

After installation is complete, no further configuration should be needed.

If you have installed orca, then for some reason plotly.py was unable to
locate it. In this case, set the plotly.io.orca.config.executable
property to the full path of your orca executable. For example:

>>> plotly.io.orca.config.executable = '/path/to/orca'

After updating this executable property, try the export operation again.
If it is successful then you may want to save this configuration so that it
will be applied automatically in future sessions. You can do this as follows:

>>> plotly.io.orca.config.save()

If you’re still having trouble, feel free to ask for help on the forums at
https://community.plotly.com/c/api/python