Plotly missing orca
Asked Answered
P

9

16

I have small problem when exporting static chart using plotly.

Plotly does not correctly recognize that I have orca installed and I have still error related to missing orca. I try to change the orca directory but it is still not working. Anyone who knows what is wrong?

My code:

import plotly.graph_objects as go
import orca
import plotly

#%%
fig = go.Figure(data=go.Candlestick(x=pricedata.index,
                    open=pricedata['bidopen'],
                    high=pricedata['bidhigh'],
                    low=pricedata['bidlow'],
                    close=pricedata['bidclose']),)
#%%
fig.show()

#%%
plotly.io.orca.config.executable = r'C:\Users\Kuba\AppData\Local\Programs\Python\Python37\Lib\site-packages\orca'
plotly.io.orca.config.save()

#%%

fig.write_image("images/fig1.png")

Here is described how to solve it but it does not work for me:

https://plot.ly/python/orca-management/#configuring-the-executable

The orca version is 1.5.1

Thanks.

B.

EDIT:

Error msg:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
c:\Users\Kuba\Documents\GitHub\frstalg\FXCM Stuff\LiveMyStrategyNOTEBOOK-20191017.py in 
      1 
----> 2 fig.write_image("images/fig1.png")

~\AppData\Local\Programs\Python\Python37\lib\site-packages\plotly\basedatatypes.py in write_image(self, *args, **kwargs)
   2686         import plotly.io as pio
   2687 
-> 2688         return pio.write_image(self, *args, **kwargs)
   2689 
   2690     # Static helpers

~\AppData\Local\Programs\Python\Python37\lib\site-packages\plotly\io\_orca.py in write_image(fig, file, format, scale, width, height, validate)
   1703     # Do this first so we don't create a file if image conversion fails
   1704     img_data = to_image(
-> 1705         fig, format=format, scale=scale, width=width, height=height, validate=validate
   1706     )
   1707 

~\AppData\Local\Programs\Python\Python37\lib\site-packages\plotly\io\_orca.py in to_image(fig, format, width, height, scale, validate)
   1480     # Make sure orca sever is running
   1481     # -------------------------------
-> 1482     ensure_server()
   1483 
   1484     # Handle defaults

~\AppData\Local\Programs\Python\Python37\lib\site-packages\plotly\io\_orca.py in ensure_server()
   1342     # Validate orca executable
   1343     if status.state == "unvalidated":
-> 1344         validate_executable()
   1345 
   1346     # Acquire lock to make sure that we keep the properties of orca_state

~\AppData\Local\Programs\Python\Python37\lib\site-packages\plotly\io\_orca.py in validate_executable()
   1041                 executable=config.executable,
   1042                 formatted_path=formatted_path,
-> 1043                 instructions=install_location_instructions,
   1044             )
   1045         )

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 'C:\Users\Kuba\AppData\Local\Programs\Python\Python37\Lib\site-packages\orca' on the following path:
    C:\Users\Kuba\AppData\Local\Programs\Python\Python37\lib\site-packages
    C:\Program Files\Microsoft MPI\Bin\
    C:\Program Files (x86)\Common Files\Oracle\Java\javapath
    C:\Program Files (x86)\Intel\iCLS Client\
    C:\Program Files\Intel\iCLS Client\
    C:\Windows\system32
    C:\Windows
    C:\Windows\System32\Wbem
    C:\Windows\System32\WindowsPowerShell\v1.0\
    C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common
    C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL
    C:\Program Files\Intel\Intel(R) Management Engine Components\DAL
    C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT
    C:\Program Files\Intel\Intel(R) Management Engine Components\IPT
    C:\WINDOWS\system32
    C:\WINDOWS
    C:\WINDOWS\System32\Wbem
    C:\WINDOWS\System32\WindowsPowerShell\v1.0\
    C:\WINDOWS\System32\OpenSSH\
    C:\Program Files\Git\cmd
    C:\Program Files\dotnet\
    C:\Program Files\PuTTY\
    C:\Users\Kuba\AppData\Local\Programs\Python\Python37\Scripts\
    C:\Users\Kuba\AppData\Local\Programs\Python\Python37\
    C:\Users\Kuba\AppData\Local\Microsoft\WindowsApps
    C:\Users\Kuba\AppData\Local\Programs\Microsoft VS Code\bin
    C:\Users\Kuba\AppData\Local\GitHubDesktop\bin
    %USERPROFILE%\AppData\Local\Microsoft\WindowsApps

    C:\Users\Kuba\AppData\Local\Programs\Python\Python37\lib\site-packages\numpy\.libs

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
Plasia answered 20/10, 2019 at 14:10 Comment(2)
whats the error message?Juju
I edited the original post.Plasia
C
12

From the plotly docs

pip install -U kaleido
Chatav answered 11/2, 2021 at 18:38 Comment(1)
Thank you, I was trying to use Orca and it was a nightmareAyres
W
9

try kaleido, it worked for me. It is an alternative to orca

conda install -c plotly python-kaleido
Waldemar answered 11/1, 2021 at 17:9 Comment(0)
P
6

What worked for me on Windows with Pycharm and Python 3.6 is:

  • Following https://github.com/plotly/orca#installation - Method 4: Standalone binaries:

    • Download windows-release.zip from https://github.com/plotly/orca/releases
    • Install the executable
    • Right click on the desktop newly created Orca icon to get the path where the application was installed.
  • From the plotly\io folder (in my case C:\Users\ventafri\AppData\Local\Programs\Python\Python36\Lib\site-packages\plotly\io) open _orca.py

Substitute:

 # Try to find an executable
 # -------------------------
 # Search for executable name or path in config.executable
 executable = which(config.executable)
 path = os.environ.get("PATH", os.defpath)
 formatted_path = path.replace(os.pathsep, "\n    ")

with:

# Try to find an executable
# -------------------------
# Search for executable name or path in config.executable
executable = r"C:\Users\ventafri\AppData\Local\Programs\orca\orca.exe"
path = os.environ.get("PATH", os.defpath)
formatted_path = path.replace(os.pathsep, "\n    ")
Pilothouse answered 23/12, 2019 at 22:22 Comment(4)
Sorry for late reply. Your solution did not work for me but I found workaround using fig.to_html() which then I can open and see the chart and subsequently transform to picture. Maybe your solution will for someone else.Plasia
I had this issue with a PyCharm installation of orca and plotly, and this solution works perfectly thereNecktie
I am running the following line: C:\WINDOWS\system32>orca graph "{ \"data\": [{\"y\": [1,2,1]}] }" -o fig.png and nothing is happening. Any idea?Bank
Instead of editing the python library (not recommended as changes will be overwritten when updating it), you could also set the executable path in your script, as described in the error message and suggested by the author Sanch: import plotly and then plotly.io.orca.config.executable = 'C:\\Users\\your_username\\AppData\\Local\\Programs\\orca\\orca.exe'Dulsea
M
6
#Try with installing these packages on Colab:
!pip install plotly==4.7.1
!wget https://github.com/plotly/orca/releases/download/v1.2.1/orca-1.2.1- 
x86_64.AppImage -O /usr/local/bin/orca
!chmod +x /usr/local/bin/orca
!apt-get install xvfb libgtk2.0-0 libgconf-2-4
import plotly.graph_objects as go
Then generate your figure- not including code here -Save the figure as:
fig.show()
fig.write_image("figname.png")#change format if needed
Or save the generated figure on Google drive as:
fig.show()
fig.write_image("gdrive/My Drive/destinationfolder/figname.png")
Murrain answered 12/5, 2020 at 10:36 Comment(1)
is kaleido impossible with colab or something?Gehlenite
G
4

Susanna's answer is probably much better, but what worked for me is to downgrade to orca 1.2.1:

conda remove plotly plotly-orca
conda install -c plotly plotly-orca==1.2.1
Glazed answered 13/4, 2020 at 12:56 Comment(0)
H
1

What worked for me was installing the .exe file directly from the Github: https://github.com/plotly/orca/releases

And then running this with the file path to the newly created .exe file.

import plotly

plotly.io.orca.config.executable = '...../orca/orca.exe'
Hemistich answered 1/10, 2020 at 15:34 Comment(0)
C
0

I had a similar issue when trying to generate static images with plotly in jupyter notebook with kernel using other than base conda environment.

I had to install plotly-orca in the base environment as well for it to work.

Crankcase answered 8/5, 2020 at 15:49 Comment(0)
A
0

I'm also facing the same issue, you can use kaleido to save static image while working with plotly.

https://medium.com/plotly/introducing-kaleido-b03c4b7b1d81

Airlie answered 1/12, 2020 at 6:46 Comment(0)
G
-2

if you are still facing dependencies issues may be install pip install urbansim may resolve it.

Giselagiselbert answered 19/8, 2022 at 22:56 Comment(1)
This answer should be a comment!Gradualism

© 2022 - 2024 — McMap. All rights reserved.