Problem with Plotly-Orca to export as PDF

Hi all,

I have trouble with using Plotly-Orca to export plots as PDFs and I assume the problem comes from the language of my operating system (Ubuntu 18.04 LTS natively installed in French).

Everything seems correctly installed and up-to-date.

I’ve been using Plotly with Python for research and it works well. However, now I would like to export my plots to something that can be integrated in a PDFLatex document. I tried SVG but it breaks the font size and style. Therefore I would like to export my plots as PDFs.

I followed the instructions at:
Static image export in Python

Orca is installed correctly with Miniconda:

$ which orca
/usr/bin/orca
$ orca --version
3.28.0

I am using the up-to-date Python executable that was downloaded by Miniconda:

$ python --version
Python 3.7.1

And an up-to-date version of Plotly, where orca is correctly configured:

>>> import plotly
>>> plotly.__version__
'3.4.1'
>>> plotly.io.orca.config.executable
'orca'

When executing line plotly.io.write_image(fig, 'testpdf.pdf'), I have the following error, and my guess is that is it linked to the help message of Orca being in French and not in English as Plotly may expect:

The orca executable is required in order to export figures as static images,
but the executable that was found at ‘/usr/bin/orca’
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 at
GitHub - plotly/orca: Command line application for generating static images of interactive plotly charts.

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

The error encountered is that unexpected output was returned by the command
$ /usr/bin/orca --help

b"Usage\xc2\xa0: orca [-h] [-v] [-r] [-s] [-l] [-e OPTION] [-d OPTION] [-p NOM]\n [-u R\xc3\x89PERTOIRE] [–debug-file FICHIER] [–debug]\n\nParam\xc3\xa8tres facultatifs:\n -h, --help Montrer ce message d\xe2\x80\x99aide et quitter\n -v, --version 3.28.0\n -r, --replace Remplace une instance actuellement lanc\xc3\xa9e de\n ce lecteur d’\xc3\xa9cran\n -s, --setup D\xc3\xa9finit les pr\xc3\xa9f\xc3\xa9rences utilisateur (mode\n graphique)\n -l, --list-apps Affiche les applications lanc\xc3\xa9es connues\n -e OPTION, --enable OPTION Force l\xe2\x80\x99utilisation de l\xe2\x80\x99option\n -d OPTION, --disable OPTION Emp\xc3\xaache l\xe2\x80\x99utilisation de l\xe2\x80\x99option\n -p NOM, --profile NOM Charge le profil\n -u R\xc3\x89PERTOIRE, --user-prefs R\xc3\x89PERTOIRE\n Utilise un r\xc3\xa9pertoire alternatif pour les\n pr\xc3\xa9f\xc3\xa9rences des utilisateurs\n --debug-file FICHIER Envoie la sortie de d\xc3\xa9bogage dans le fichier\n indiqu\xc3\xa9\n --debug Envoie la sortie de d\xc3\xa9bogage dans debug-AAAA-\n MM-JJ-HH:MM:SS.out\n\nRapportez les bogues \xc3\xa0 orca-list@gnome.org.\n"

Indeed, when I run orca --help, the help message is in French (as reported by the error).

Have you encountered the same error before? Any hints?

Thanks in advance!

1 Like

@MFolschette, Currently, Plotly’s orca is on version 1.1.1 and not 3.28.0 and we haven’t added localization yet so the orca that’s installed and set in plotly.io.orca.config.executable doesn’t seem to be the right one.

If you locate plotly-orca that was installed via miniconda and then set that location with plotly.io.orca.config.executable = '/path/to/miniconda/orca', I think that should work.

Indeed, that was the solution! Thank you very much.

Problem: A software named Orca was already installed from the official Ubuntu repositories, and orca was pointing to it and not to Plotly-Orca. Solution: I changed plotly.io.orca.config.executable to point specifically to the Miniconda Orca binary.

If I may suggest, this potential problem should be mentioned in the online help or in the error message, as it may easily happened to other people, especially since the help suggests to install it with Conda/Miniconda.

@MFolschette, That’s a good idea :slight_smile: and I think we should implement it. Feel free to open a PR/Issue at https://github.com/plotly/plotly.py and link to this thread to provide some additional context.

Done!
Thank you for your help.
How should I mark this thread as solved?

Hi all

I come across to this issue also but I dont understand the instruction given

Is this line to be inserted within my code?
Is it to be inserted in the Orca.py ?
Is it to be inserted in plotly.py?

Where can I do that?

Cheers

You would add plotly.io.orca.config.executable = '/path/to/orca' in your code somewhere above plotly.io.write_image(fig, 'testpdf.pdf').
`

1 Like

Fantastic!!

thank you