I’m trying to save an image offline in a Docker container for my discord bot. It works on my local machine but running the same code in the container I get this error:
/opt/conda/bin/orca: line 11: 76 Terminated xvfb-run -a /opt/conda/bin/plotly-orca "$@"
Traceback (most recent call last):
File "bot/discordBot.py", line 15, in <module>
import chart as c
File "/bot/chart.py", line 91, in <module>
print(get_plot("BTC"))
File "/bot/chart.py", line 85, in get_plot
pio.write_image(fig, 'fig1.png', validate=True)
File "/opt/conda/lib/python3.7/site-packages/plotly/io/_orca.py", line 1512, in write_image
validate=validate)
File "/opt/conda/lib/python3.7/site-packages/plotly/io/_orca.py", line 1417, 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
Yet, running this code gives me an output without error:
in terms of debugging, I think I’d recommend trying out the image from that PR and see if that works in your environment (not necessarily from plotly.py, just running from the command line would be enough). Then work your way backwards to the configuration you want alongside discord.
Another idea. You could start the orca server in debug mode from the command line inside your docker container and see if you get any more informative error messages.
So funny enough I tried that exact docker config and orca isn’t being recognized. My config runs fine normally since orca --help works as intended and pio.write_image(go.Figure(data=[{'y': [1, 3, 2]}]), 'simple_fig.png')
works as well. --debug unfortunately didn’t provide any useful information.
I’m more focused on why this error is coming up for my own figure
File "/opt/conda/lib/python3.7/site-packages/plotly/io/_orca.py", line 1512, in write_image
**validate=validate**)
File "/opt/conda/lib/python3.7/site-packages/plotly/io/_orca.py", line 1417, 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**
Ok, interesting so you can successfully write out this simple figure to an image? I think I miseed that before. What kind of traces do you have in your figure? I’m particularly wondering if there are any mapbox or WebGL accelerated trace types.
@bjodah, I would like to know how can I do the same.
I have never worked with xvfb (run).
Actually, I don’t even know what that is.
Can you, please, give me some more detail?
I get the error at a specific image. Every other image works just fine!
It’s very important that you not have a file named plotly.py in the same directory as the Python script you’re running, and this includes not naming the script itself plotly.py, otherwise importing plotly can fail with mysterious error messages.
Beyond this, most import problems or AttributeErrors can be traced back to having multiple versions of plotly installed, for example once with conda and once with pip. It’s often worthwhile to uninstall with both methods before following the Getting Started instructions from scratch with one or the other. You can run the following commands in a terminal to fully remove plotly before installing again: