💸 Reduce costs by consolidating proprietary analytics & reporting software to open-source & Dash.
Challenge us to replace your analytics with Dash and reduce costs.

Unable to save to pdf with Orca even though the package is visible as installed

Hi,

I’m relatively new to Python. I’d like to use Orca and Plotly to save a pdf output of my graph in Plotly. I’m using PyCharm and have installed plotly, orca, requests, electron and psutil from the PyCharm interface. In the directory where all other packages are downloaded, I can see that orca is also available C:\Users\uname\AppDara\Local\Programs\Python\Python37\Lib\site-packages\orca .

However, when I try to run:

plotly.io.write_image(fig,‘images/testpdf.pdf’)

I get the error:

Traceback (most recent call last):
File “C:/Users/uname/PycharmProjects/untitled/currency2.py”, line 75, in
plotly.io.write_image(fig,‘images/testpdf.pdf’)
File “C:\Users\uname\AppDara\Local\Programs\Python\Python37\lib\site-packages\plotly\io_orca.py”, line 1705, in write_image
fig, format=format, scale=scale, width=width, height=height, validate=validate
File “C:\Users\uname\AppDara\Local\Programs\Python\Python37\lib\site-packages\plotly\io_orca.py”, line 1482, in to_image
ensure_server()
File “C:\Users\uname\AppDara\Local\Programs\Python\Python37\lib\site-packages\plotly\io_orca.py”, line 1344, in ensure_server
validate_executable()
File “C:\Users\uname\AppDara\Local\Programs\Python\Python37\lib\site-packages\plotly\io_orca.py”, line 1043, in validate_executable
instructions=install_location_instructions,
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/uname/AppDara/Local/Programs/Python/Python37/Lib/site-packages/orca’ on the following path:
C:\Users\uname\AppDara\Local\Programs\Python\Python37\Scripts
C:\WINDOWS\system32
C:\WINDOWS
C:\WINDOWS\System32\Wbem
C:\WINDOWS\System32\WindowsPowerShell\v1.0
C:\WINDOWS\System32\OpenSSH
C:\Users\uname\AppData\Local\Microsoft\WindowsApps

C:\Users\uname\AppDara\Local\Programs\Python\Python37\lib\site-packages\numpy\.libs
C:\Users\uname\AppDara\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.plotly.com/c/api/python

I also read to point the orca executable to point to the directory where orca is installed and I still get the same error.

Can anyone please help to resolve this?

Many thanks!

hi

does it work if you do

$ orca graph "{ \"data\": [{\"y\": [1,2,1]}] }" -o fig.png

in the terminal window ?
The thing is that i have never managed to make this save image function work on windows and on mac. So i went around by using this function in Jupyter like that

call([‘orca’, ‘graph’, json.dumps(name_of_your_figure, cls=plotly.utils.PlotlyJSONEncoder), ‘-o’, ‘name_of_your_output_file’,’-d’,‘images’,’-f’,‘svg’])

it works most of the time but the problem is that sometimes it will not save the image because for some reason it considers the image too big
(error message in that case is the misleading
“FileNotFoundError: [WinError 206] The filename or extension is too long” )

Then I have found other people with the same problem on the forum and asked them if they found the solution and never did and had to give up on plotly.

not exactly the most secure set up if you have to rely on it :slight_smile:
I believe unfortunately that it is close to hopeless.
Good luck