I think I made some progress by setting up a virtual environment with specific versions of plotly.py and dependencies:
#!/bin/bash
conda create -n plotlywidget python=3.6
conda activate plotlywidget
pip install plotly==3.4.0
pip install plotly-orca==1.1.1
pip install "notebook>=5.3" "ipywidgets>=7.2"
pip install jupyterlab==0.35
export NODE_OPTIONS=--max-old-space-size=4096
jupyter labextension install @jupyter-widgets/jupyterlab-manager@0.38 --no-build
jupyter labextension install plotlywidget@0.5.0 --no-build
jupyter labextension install @jupyterlab/plotly-extension@0.18 --no-build
jupyter lab build
conda deactivate plotlywidget
HTML export worked correctly!
I am able to export SVG without error messages from within Jupyter. However, when I try to open the resulting SVG file in Adobe Illustrator CC 2018, I get an error message about the file being corrupt, and Illustrator does not open the file. I can open the SVG file in a web browser, but there is a rendering error message:
This page contains the following errors:
error on line 1 at column 479653: attributes construct error
Below is a rendering of the page up to the first error.
The problem appears to be localized to the figure legend. The legend only shows the color marker for the first trace or group of data; no other legend items are shown.
Separately from SVG issues, I ran into the following error message when attempting to export PNG or PDF from the Jupyter notebook via plotly.io.write_image()
:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-14-c622c1ec90c2> in <module>
1 # Write image using orca
----> 2 pio.write_image(fig, '/tmp/3d_rotated.pdf', validate=False)
~/anaconda3/lib/python3.6/site-packages/plotly/io/_orca.py in write_image(fig, file, format, scale, width, height, validate)
1486 width=width,
1487 height=height,
-> 1488 validate=validate)
1489
1490 # Open file
~/anaconda3/lib/python3.6/site-packages/plotly/io/_orca.py in to_image(fig, format, width, height, scale, validate)
1391 Unfortunately, we don't yet know of an easy way to install poppler on Windows.
1392 """
-> 1393 raise ValueError(err_message)
1394
1395
ValueError:
The image request was rejected by the orca conversion utility
with the following error:
525: plotly.js error
From reading your other comments on the forum related to this subject, it looks like specific versions of components are needed for plotlywidget to work. Is the version of orca
that I am installing the correct version?
pip install plotly-orca==1.1.1
Are there other Python libraries that are required for exporting PNG and PDF?
I thought there might be additional dependencies for exporting these formats, but the Jupyter error message is the same with these libraries:
pip install psutil==5.4.8
conda install -c conda-forge poppler -y
I’m on OS X and also tried installing poppler
from Homebrew: brew install poppler
. This included several libraries for image handling libpng, libjpeg, etc.
Are there perhaps other dependencies that I overlooked?
Thanks very much for your help!