Errors when output figures to pdf in jupyter notebook


#1

Hi all:

I having the following errors when trying to output the figures to pdf in jupyter notebook using SOS kernel. Any comments or suggestions are greatly appreciated. Thanks a lot.

Best Regards
Rongguo


ValueError Traceback (most recent call last)
script_3986609300093530748 in
plotly.io.orca.config.executable = ‘C:/Users/rongzhou/AppData/Local/Programs/orca’
plotly.io.orca.config.save()
----> plotly.io.write_image(fig, ‘testpdf.pdf’)

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:/Users/rongzhou/AppData/Local/Programs/orca’ on the following path:
C:\Users\rongzhou\Downloads\cmder\bin
C:\Users\rongzhou\Downloads\cmder\vendor\bin
C:\Users\rongzhou\Downloads\cmder\vendor\conemu-maximus5\ConEmu\Scripts
C:\Users\rongzhou\Downloads\cmder\vendor\conemu-maximus5
C:\Users\rongzhou\Downloads\cmder\vendor\conemu-maximus5\ConEmu
C:\ProgramData\DockerDesktop\version-bin
C:\Program Files\Docker\Docker\Resources\bin
C:\WINDOWS\system32
C:\WINDOWS
C:\WINDOWS\System32\Wbem
C:\WINDOWS\System32\WindowsPowerShell\v1.0
C:\Program Files (x86)\Qualcomm\PHMDB
C:\Program Files (x86)\Sennheiser\SoftphoneSDK
C:\Program Files\MATLAB\R2017a\runtime\win64
C:\Program Files\MATLAB\R2017a\bin
C:\WINDOWS
C:\WINDOWS\System32
C:\WINDOWS\System32\wbem
C:\WINDOWS\system32
C:\WINDOWS
C:\WINDOWS\System32\Wbem
C:\WINDOWS\System32\WindowsPowerShell\v1.0
C:\Program Files\Intel\WiFi\bin
C:\Program Files\Common Files\Intel\WirelessCommon
C:\Program Files\Git\cmd
C:\Users\rongzhou\AppData\Local\Programs\Python\Python37\Scripts
C:\Users\rongzhou\AppData\Local\Programs\Python\Python37
C:\Users\rongzhou\AppData\Local\Microsoft\WindowsApps
C:\Users\rongzhou\AppData\Local\Programs\Microsoft VS Code\bin
C:\Program Files\Docker Toolbox
C:\Program Files\Docker Toolbox
C:\Program Files\Docker Toolbox
C:\Users\rongzhou\AppData\Local\GitHubDesktop\bin
C:\Program Files\Docker Toolbox
C:\Program Files\Git\cmd
C:\Program Files\Git\mingw64\bin
C:\Program Files\Git\usr\bin
C:\Users\rongzhou\Downloads\cmder
C:\Users\rongzhou\AppData\Local\Programs\Python\Python37\lib\site-packages\numpy.libs
C:\Users\rongzhou\AppData\Local\Programs\Python\Python37\lib\site-packages\scipy\extra-dll

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.plot.ly/c/api/python


#2

The python code I was using is as the following:

from plotly.offline import iplot, init_notebook_mode
import plotly.graph_objs as go
import plotly.io as pio
import plotly
import os
import numpy as np
init_notebook_mode(connected=True)

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’
});
iplot(fig)
if not os.path.exists(‘C:\Rongguo\NPI Projects’):
os.mkdir(‘C:\Rongguo\NPI Projects’)

plotly.io.orca.config.executable = ‘C:/Users/rongzhou/AppData/Local/Programs/orca’
plotly.io.orca.config.save()
plotly.io.write_image(fig, ‘testpdf.pdf’)


#3

Hi @rgzhou,

How did you install orca? Can you verify that you see the orca executable at C:/Users/rongzhou/AppData/Local/Programs/orca? My only initial thought is to try reversing the slash direction.

plotly.io.orca.config.executable = r'C:\Users\rongzhou\AppData\Local\Programs\orca'

Note the leading r character which keeps the backslashes from being interpreted as the start of special characters.

Does that help?
-Jon