Cannot write_image with orca

Hello everybody,

I am unable to export any image from plotly since:

The orca executable is required in order to export figures as static images,
but the executable that was found at ‘C:\Program Files\orca\orca.EXE’
does not seem to be a valid plotly orca executable. Please refer to the end of
this message for details on what went wrong.

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 …
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
….

Here is the error that was returned by the command
$ C:\Program Files\orca\orca.EXE --help

[Return code: 1]

Orca returned code 1 because I have killed the Orca process using the task manager.

I have this kind of problem only when running the script on a Windows Server 2016 machine trought an asp.net core application.
The same application and scripts works fine on my machine but not on the server.

I’ve installed python, plotly and all the dependencies on the server using pip but I’ve installed Orca using the Windows installation in github a and added the folder that contains orca.exe to the PATH environment variable.

So when my asp.net core application calls the python script on the task manager Python process is created, after a few seconds orca process is created, but it seems to do nothing.
When I kill Orca.exe proccess I recieve the error message above.
But If I lunch the script uscing the command prompt everything works fine.
Any suggestion?

Thank you very much.

Furthermore I have created the exe file of the script using pyinstaller. When I execute the file then the error is:
For some reason plotly.py 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\uname\AppData\Roaming\npm\orca.CMD
version: 1.2.1
port: 57721
pid: 15196
command: ['C:\\Users\\uname\\AppData\\Roaming\\npm\\orca.CMD', 'serve', '-p', '57721', '--plotly', 'C:\\Development\\Python\\SaveImage\\compiled\\dist\\myimage\\plotly\\package_data\\plotly.min.js', '--graph-only', '--mathjax', 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js'] 

This happens on my machine and on the server…

Hi @rojasjo,

One thing that might be helpful is to manually run the orca serve command from the windows command prompt on the server, and add the --debug flag. The orca.status operation shows the command arguments that were used. e.g.

command: ['C:\\Users\\uname\\AppData\\Roaming\\npm\\orca.CMD', 'serve', '-p', '57721', '--plotly', 'C:\\Development\\Python\\SaveImage\\compiled\\dist\\myimage\\plotly\\package_data\\plotly.min.js', '--graph-only', '--mathjax', 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js'] 

So you’d want something like

C:\Users\uname\AppData\Roaming\npm\orca.CMD serve -p 57721 --plotly C:\Development\Python\SaveImage\compiled\dist\myimage\plotly\package_data\plotly.min.js --graph-only --mathjax https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js --debug

The hope is that the --debug flag will produce some useful output to help us figure out what’s going wrong.

-Jon

Hello @jmmease,

I have executed the command you kindly wrote for me, the result is:

Spinning up server with pid: 19224
{“severity”:“ERROR”,“textPayload”:“Error: Provided path to plotly.js bundle does not exist and does not correspond to a release version”}

But now I understand that my Python exe has somewhere the link to orca as my workstation and not the path where orca is installed beacuse when I execute it on the server from the command prompt:
‘C:\Users\uname\AppData\Roaming\npm\orca.CMD’ is not recognized as an internal or external command, operable program or batch file.

Change the path to orca.exe then I recieve the same error:
C:\Program Files\orca>orca.exe serve -p 57721 --plotly C:\Development\Python\SaveImage\compiled\dist\myimage\plotly\package_data\plotly.min.js --graph-only --mathjax …://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js --debug

C:\Program Files\orca>
Spinning up server with pid: 8416
{“severity”:“ERROR”,“textPayload”:“Error: Provided path to plotly.js bundle does not exist and does not correspond to a release version”}

Now I understand that in the folder where I have the exe file generated by pyinstaller there is not such folder plotly…I i put plotly.min.js still I get the same error:

C:\Program Files\orca>orca.exe serve -p 57721 --plotly Pathto\plotly\package_data\plotly.min.js --graph-only --mathjax …://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js --debug
C:\Program Files\orca>
Spinning up server with pid: 9552
{“severity”:“ERROR”,“textPayload”:“Error: Provided path to plotly.js bundle does not exist and does not correspond to a release version”}

But if I execute orca without passing the path to plotly.min.js then it seems to work:
C:\Program Files\orca>orca.exe serve -p 57721 --plotly --graph-only --mathjax …://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js --debug

C:\Program Files\orca>
Spinning up server with pid: 2400
created index-f4e314c0-5cd4-4d24-9879-e2d3ba1e648d.html for plotly-graph component
Listening on port 57721 after a 4627.316088 ms bootup
Open routes: /

Now the big question, are you awere where I can change this command when generating the exe file from the Python script or if I can change this command even afert have compiled the program?

Thank you very much for your assistance.

Looking in the plotly site I found how to see orca configuration:

orca configuration

executable: orca
port: None
timeout: None
default_width: None
default_height: None
default_scale: 1
default_format: png
mathjax: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js
topojson: None
mapbox_access_token: None

constants

plotlyjs: /Users/jmmease/Plotly/repos/plotly.py/plotly/package_data/plotly.min.js
config_file: /Users/jmmease/.plotly/.orca

The problem is that on Windows there is not such file, I mean C:/Users/username/.plotly doesn’t exists… not on my workstation either on the server.

Thank you again.

Hi @rojasjo,

This is very helpful information. plotly.py directs orca to use the version of plotly.js (the JavaScript library) that comes bundled with plotly.py. This is located in the package_data directory under the top-level plotly package directory. I’m not very familiar with PyInstaller, but is there a way to make sure that package data is included in the resulting installed application?

What output do you get if you run the following from within your compiled application?

import plotly.io as pio
print(pio.orca.config.plotlyjs)

The question is, is there anything you can do in the PyInstaller configuration to make sure the plotly.js bundle shows up at this location.

Unfortunately, the pio.orca.config.plotlyjs path is read-only so you can’t change the path in the public API. But I’m open to making this more configurable if we come up with a better workflow for use inside PyInstaller. If you want to play around with changing the path, you can do so in the following private/unstable way:

import plotly.io as pio
pio.orca.config._constants['plotlyjs']  = new_plotlyjs

If internet access is available then you could set this to the string 'latest' to tell orca to load the latest stable version of plotly.js from the online CDN.

The C:/Users/username/.plotly directory is optional, so that fact that it’s missing shouldn’t be a problem in itself.

Hope that helps,
-Jon

Hi All,

Can anyone share an example on setting below confing

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

If I want to use Orca to generate static images on Windows box do I need to install Python? Is there any example of how to use Orca with Plotly on Windows box? This is the critical part of a project I am working on.

Thanks

Hi all,

I found a solution that worked for Windows:

Try to install the Orca executable here https://github.com/plotly/orca/releases/download/v1.3.1/windows-release.zip

Then, you should do exactly what is written here:

https://github.com/plotly/orca#windows

Hope it helps.

Cheers!

In the terminal
$ which orca
‘/-/anaconda3/bin/orca’ (’/path/to/orca’)

plotly.io.orca.config.executable = ‘/-/anaconda3/bin/orca’
plotly.io.orca.config.save()

As a heads-up: since July 2019, the new and recommended way to export static images from Plotly.py is to use Kaleido, which is trivial to install with just pip install kaleido and will automatically be picked up by versions of Plotly.py greater than 4.9!

Nicolas,
I am using an older version of plotly soI need orca.
I am still getting usual message:

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

Even though Orca is installed:

(david_env) $ which orca
~/.conda/envs/david_env/bin/orca

and even though

print(plotly.io.orca.config.executable)

returns ‘~/.conda/envs/david_env/bin/orca’

I need this to work in the virtual environment that is setup.
Thank you for your help.

EDIT: Actually I just needed to replace ~ by /home/$USER

Now I get this
The plotly.io.orca.config.use_xvfb property is set to True, but the
xvfb-run executable could not be found on the system path.

Searched for the executable ‘xvfb-run’ on the following path:

@dlesaffre if you can install Kaleido, this message will go away (it’s a bit misleading right now: if it finds neither Orca nor Kaleido it recommends Orca even though we recommend Kaleido… this message will change in the next version of Plotly.py :slight_smile: ) … In general Kaleido is easier to work with than Orca and it’s easier to debug this kind of situation. Just pip install kaleido and you’re good :slight_smile:

Thank you for the quick answer. Unfortunately I am having issues installing that package:

Solving environment: |
Found conflicts! Looking for incompatible packages.
This can take several minutes. Press CTRL-C to abort.
failed

UnsatisfiableError: The following specifications were found to be incompatible with each other:

Output in format: Requested package → Available versionsThe following specifications were found to be incompatible with your system:

  • feature:/linux-64::__glibc==2.31=0
  • feature:|@/linux-64::__glibc==2.31=0
  • python-kaleido → kaleido-core=0.2.1 → __glibc[version=‘>=2.17,<3.0.a0’]

Your installed version is: 2.31

I updated plotly to the latest version too

I fixed the issue with orca by installing xvfb.