orca
orca copied to clipboard
Conversion fails with Scattergl
If I want to create an offline plot that contains the plotly Scattergl command I get an error message.
Consider the example below (which is run through a jupyter notebook with linux host and windows guest):
import plotly.io as pio
import plotly.graph_objs as go
traces = []
traces.append(
go.Scattergl(
y=[1, 3, 2]))
layout = go.Layout(
width=800)
fig = go.Figure(data=traces, layout=layout)
# Plot and embed in ipython notebook
pio.write_image(fig, "simple_fig.png")
This will give the following error:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-10-92d1a9d074fc> in <module>()
14
15 # Plot and embed in ipython notebook
---> 16 pio.write_image(fig, "simple_fig.png")
~/usr/local/lib/python3.6/site-packages/plotly/io/_orca.py in write_image(fig, file, format, scale, width, height, validate)
1483 width=width,
1484 height=height,
-> 1485 validate=validate)
1486
1487 # Open file
~/usr/local/lib/python3.6/site-packages/plotly/io/_orca.py in to_image(fig, format, width, height, scale, validate)
1388 Unfortunately, we don't yet know of an easy way to install poppler on Windows.
1389 """
-> 1390 raise ValueError(err_message)
1391
1392
ValueError:
The image request was rejected by the orca conversion utility
with the following error:
525: plotly.js error
Changing Scattergl to Scatter will make the example work.
Thanks very much for reporting!
A few questions:
- could you tell how you installed
orca
? - which version of orca are you running?
- have you tried running your script in a plain python context (i.e. outside of a notebook)?
@jonmmease any ideas on why this could happen?
- Below is the way I installed orca.
- I am running orca version 1.2.1.
The machine I'm running on is basically configured like this: https://github.com/Nikolai-Hlubek/vagrant-centos7-jupyter
Insall orca for plotly offline plotting
Install xvfb for headless server and chromium
> sudo yum install chromedriver chromium xorg-x11-server-Xvfb
Move orca binary to server and than to folder
> mkdir plotly-orca
> mv orca-1.2.1-x86_64.AppImage plotly-orca/
Create shell script to run orca through xvfb
#!/bin/bash
xvfb-run -a ~/plotly-orca/orca-1.2.1-x86_64.AppImage "$@"
Create symbolic link to some location that is in the path
> ln -s ~/plotly-orca/orca.sh usr/local/bin/orca
Verify that it is running
orca --help
I tried testing Scatter/Scattergl on the jupyter linux guest and I get the following error with Scattergl there:
... pio.write_image(fig, "simple_fig.png")
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "/home/nhlubek/usr/local/lib/python3.6/site-packages/plotly/io/_orca.py", line 1593, in write_image
validate=validate)
File "/home/nhlubek/usr/local/lib/python3.6/site-packages/plotly/io/_orca.py", line 1498, in to_image
raise ValueError(err_message)
ValueError:
The image request was rejected by the orca conversion utility
with the following error:
525: plotly.js error
Scatter works.
Additionally now I have a lot of orca-...AppImage processes running. Do they get closed eventually?
Hi @Nikolai-Hlubek ,
As of plotly.py 3.10, you can let plotly.py handle calling xvfb for you. See https://github.com/plotly/plotly.py/pull/1523. This is worth a try because then xvfb will be called with arguments/flags that should work with all of the plotly trace types.
With this approach you make sure xvfb is installed and on the path, but you point plotly.py to the plain orca executable (not the script that calls orca with xvfb). Then you set
import plotly.io as pio
pio.orca.config.use_xvfb = True
Additionally now I have a lot of orca-...AppImage processes running. Do they get closed eventually?
You should end up with 3 orca/electron process when orca server starts up the first time (on the first image export by default). plotly.py attempts to shut them down when the python process is killed, but this isn't always completely reliable depending on how the process is shut down. You can manually shut down the orca server by calling
pio.orca.shutdown_server()
Dear @jonmmease
Thanks for your help. I tried your suggestion and have orca and Xvfb in the path.
$ which orca
~/usr/local/bin/orca
$ which Xvfb
/usr/bin/Xvfb
$ ls -hal ~/usr/local/bin/orca
... /home/nhlubek/usr/local/bin/orca -> /home/nhlubek/plotly-orca/orca-1.2.1-x86_64.AppImage
However I still get the same error messages as above when I run the scripts via jupyter or directly on the linux host.
Additionally after trying to run the commands a few times, opening and closing the notebook I'm left with the following processes:
16494 ? Ss 0:00 /home/nhlubek/usr/local/bin/orca --help
16538 ? Ss 0:00 /home/nhlubek/usr/local/bin/orca --version
16579 ? Ss 0:00 /home/nhlubek/usr/local/bin/orca serve -p 37472 --plotly /home/nhlubek/usr/local/lib/python3.6
16711 ? S 0:00 /usr/sbin/httpd -DFOREGROUND
16712 ? S 0:00 /usr/sbin/httpd -DFOREGROUND
16713 ? S 0:00 /usr/sbin/httpd -DFOREGROUND
16735 ? Ss 0:00 /home/nhlubek/usr/local/bin/orca --help
16775 ? Ss 0:00 /home/nhlubek/usr/local/bin/orca --version
16819 ? Ss 0:00 /home/nhlubek/usr/local/bin/orca serve -p 38772 --plotly /home/nhlubek/usr/local/lib/python3.6
16925 ? S 0:00 /usr/sbin/httpd -DFOREGROUND
16945 ? Ss 0:00 /home/nhlubek/usr/local/bin/orca --help
16990 ? Ss 0:00 /home/nhlubek/usr/local/bin/orca --version
17038 ? Ss 0:00 /home/nhlubek/usr/local/bin/orca serve -p 43606 --plotly /home/nhlubek/usr/local/lib/python3.6
17206 ? Ss 0:00 /home/nhlubek/usr/local/bin/orca --help
17251 ? Ss 0:00 /home/nhlubek/usr/local/bin/orca --version
17292 ? Ss 0:00 /home/nhlubek/usr/local/bin/orca serve -p 45273 --plotly /home/nhlubek/usr/local/lib/python3.6
I have the same problem. I export my plotly.express
scatter plots to JSON, where I replace scattergl
with scatter
as a workaround and generate my .png
files. I will experiment with this a bit longer for more elegant solution, but I already wasted several hours on basic plot dumps due to this issue.
I tested all the proposed solutions, like
import plotly.io as pio
pio.orca.config.use_xvfb = True
etc., but none of them works.
BTW, README.md
in repo root claims that default port for orca is 9091
, while plotly randomly sets the port each time. That's super unclear when using it in remote Docker containers (SSH with port forwarding & Docker on remote machine).