Why plotly-orca is unable to install via pip?
Closed this issue ยท 27 comments
I just want to know, why is that plotly-orca
not available in PyPi
.
Orca is a platform dependent command line executable (not a Python shared library like numpy for example) and when we were focused on packaging it we weren't able to find a clear approach to distribute this kind of executable using pip.
Orca is somewhat like graphviz (the executable, not the python wrapper) or git, both of which are distributed as conda packages but not as pip packages (as far as I know at least).
That said, if anyone has advice or examples of distributing platform specific command line applications using PyPI, we're definitely open to it!
if anyone finds a way to include orca in a Heroku/Google App Engine/AWS Beanstalk with dash/flask as webservers, please share. As it can't be installed through pip (using requirements.txt) I couldn't find a way to use it on those engines
it would be nice if some standard method of installation for platform dependent components like rpm/deb packages was supported.
context: I want to save an image to disk, which I expect to be simple.
Current install methods are giving me problems:
1- currently using pip to manage dependencies not conda, not planning to learn conda, not planning to move the entire project to conda to save an image
2- npm is not working
3- appimage is bizar, I don't intent to have a sub dependency of a library in a docker container to load kernel modules in order for me to save an image to disk. The work around is unclear and too much work to get an image from the screen to the disk.
@wouterdb I don't know if it's helpful but Orca can be run in server mode which exposes a simple HTTP API. If it's reachable within your network, you can then use it to produce images in several formats via simple HTTP POST calls. When possible, this is, in my opinion, the simplest and nicest solution. You can start a server listening on host's port 9091 with a simple: docker run --net=host -it quay.io/plotly/orca
.
2019-04-29T11_55_35_099Z-debug.log
(there is a permission error, but command is run with sudo)
@wouterdb It seems like you have a permission error when installing electron
. I'm not sure the problem lies with Orca itself. Can you try to manually create directory /usr/lib/node_modules/electron/.electron
?
I tried to install using npm following the instructions and got the same error as @wouterdb .
npm WARN deprecated left-pad@1.3.0: use String.prototype.padStart()
/usr/local/bin/electron -> /usr/local/lib/node_modules/electron/cli.js
/usr/local/bin/orca -> /usr/local/lib/node_modules/orca/bin/orca.js
electron@1.8.4 postinstall /usr/local/lib/node_modules/electron
node install.js
/usr/local/lib/node_modules/electron/install.js:47
throw err
^
Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/electron/.electron'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! electron@1.8.4 postinstall: node install.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the electron@1.8.4 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Running npm install -g electron@1.8.4 --unsafe-perm=true --allow-root
can solve the problem.
I tried to install orca and electron packages using npm but i get the error below when I try to export as a png file in JupyterLab.
Code:
%py
import plotly.graph_objects as go
import numpy as np
np.random.seed(1)
N = 100
x = np.random.rand(N)
y = np.random.rand(N)
colors = np.random.rand(N)
sz = np.random.rand(N) * 30
fig = go.Figure()
fig.add_trace(go.Scatter(
x=x,
y=y,
mode="markers",
marker=go.scatter.Marker(
size=sz,
color=colors,
opacity=0.6,
colorscale="Viridis"
)
))
fig.show()
fig.write_image("fig1.png")
Commands:
npm install -g electron@1.8.4 --unsafe-perm=true --allow-root
npm install -g orca
ValueError :
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
https://github.com/plotly/orca.
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.plot.ly/c/api/python
The error encountered is that no output was returned by the command
$ /usr/bin/orca --help
I am also getting the simailar error :
ValueError:
The orca executable is required to export figures as static images,
but it could not be found on the system path.
Searched for executable 'orca' on the following path:
/usr/local/opt/ruby/bin
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
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
https://github.com/plotly/orca
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.plot.ly/c/api/python
I already have orca installed :
$ pip list | grep orca
orca 1.5.3
$
It actually created directory orca-server
in python library directory.
@snmhas @suresh26k
In such cases, checking permission of /tmp/orca-build
folder could be helpful.
I had a similar problem as @wouterdb. Even though not (directly) related to the issue I added my solution below for people which might struggle as well.
I wanted to use gitlab CI to update images daily and push them to a cloud. Installing conda and using orca on the runner seemed like a lot of unnecessary overhead.
If you have a plotly (now chart_studio) account you can simply use the image function to create the bytes of the images which you can then process further. No need to install plotly-orca
from chart_studio.plotly import image as PlotlyImage
from PIL import Image as PILImage
import io
img_bytes = PlotlyImage.get(fig)
image = PILImage.open(io.BytesIO(img_bytes))
image.save("./image_name.png")
@meysampg's suggestion:
Running
npm install -g electron@1.8.4 --unsafe-perm=true --allow-root
can solve the problem.
I slightly changed it to
sudo npm install -g electron@6.1.4 orca --unsafe-perm=true -allow-root
Which installed orca to usr/bin/orca
but still failed in python:
ValueError:
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
https://github.com/plotly/orca
...
Ubuntu installation without conda / npm
- Download the .AppImage with
wget
from Orca's release page. At the time of writing it was:wget https://github.com/plotly/orca/releases/download/v1.2.1/orca-1.2.1-x86_64.AppImage
- Follow the Linux install instructions. make sure you follow the Linux troubleshooting guides as well (both) - it wasn't easy.
Thank you @DannyDannyDanny. It was very useful !
I will close this issue for now but please feel free to open a new issue if you encounter an installation issue.
Also, please try out the latest (currently v1.3.1) before reporting an issue!
I got it working.
plotly.io.orca.config.executable = r'{}' #where {} is equal to string of orca.exe location
plotly.io.orca.config.save()
wait wait what is this i have install it with pip install orca the latest version ..... but still executable.exe require???
from chart_studio.plotly import image as PlotlyImage
from PIL import Image as PILImage
import ioimg_bytes = PlotlyImage.get(fig)
image = PILImage.open(io.BytesIO(img_bytes))
image.save("./image_name.png")
it gives an error:
You must be authenticated to generate an image via json.
Note: I do it on localhost jupyter notebook
Good news! Orca is no longer really the recommended way to do static image export with Plotly :)
We have a new, pip
-installable tool called Kaleido which is superior to Orca in every way, please check it out: https://medium.com/plotly/introducing-kaleido-b03c4b7b1d81
Yeah, pip install -U kaleido
it works for me . Thanks a lot
i installed kaleido in conda. in spyder how can i show the figure in spyder plot window?
Hi @arifroni, I haven't tried it recently, but in the past I've had luck using the png
renderer in Spyder. See https://plotly.com/python/renderers/#static-image-renderers
import plotly.io as pio
pio.renderers.default = "png"
# Make a figure name fig
fig.show()
This will of course produce non-interactive figure. To launch an interactive figure in a local web browser tab, you can use the 'browser'
renderer (which doesn't use orca or kaleido). See "browser" section under https://plotly.com/python/renderers/#static-image-renderers.
import plotly.io as pio
pio.renderers.default = "browser"
# Make a figure name fig
fig.show()
Hope that helps!
Hi @arifroni, I haven't tried it recently, but in the past I've had luck using the
png
renderer in Spyder. See https://plotly.com/python/renderers/#static-image-renderersimport plotly.io as pio pio.renderers.default = "png" # Make a figure name fig fig.show()This will of course produce non-interactive figure. To launch an interactive figure in a local web browser tab, you can use the
'browser'
renderer (which doesn't use orca or kaleido). See "browser" section under https://plotly.com/python/renderers/#static-image-renderers.import plotly.io as pio pio.renderers.default = "browser" # Make a figure name fig fig.show()Hope that helps!
it works exactly as I wanted. thanks a lot :)