密谋失踪的逆戟鲸逆戟鲸

2023-09-06 08:07:16 作者:妄想温柔袭来

使用 plotly 导出静态图表时遇到小问题.

I have small problem when exporting static chart using plotly.

Plotly 无法正确识别我已安装 orca,并且仍然存在与缺少 orca 相关的错误.我尝试更改 orca 目录,但它仍然无法正常工作.有谁知道怎么回事?

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?

我的代码:

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:UsersKubaAppDataLocalProgramsPythonPython37Libsite-packagesorca'
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/#配置可执行文件

orca 版本是 1.5.1

The orca version is 1.5.1

谢谢.

B.

错误信息:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
c:UsersKubaDocumentsGitHubfrstalgFXCM StuffLiveMyStrategyNOTEBOOK-20191017.py in 
      1 
----> 2 fig.write_image("images/fig1.png")

~AppDataLocalProgramsPythonPython37libsite-packagesplotlyasedatatypes.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

~AppDataLocalProgramsPythonPython37libsite-packagesplotlyio\_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 

~AppDataLocalProgramsPythonPython37libsite-packagesplotlyio\_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

~AppDataLocalProgramsPythonPython37libsite-packagesplotlyio\_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

~AppDataLocalProgramsPythonPython37libsite-packagesplotlyio\_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:UsersKubaAppDataLocalProgramsPythonPython37Libsite-packagesorca' on the following path:
    C:UsersKubaAppDataLocalProgramsPythonPython37libsite-packages
    C:Program FilesMicrosoft MPIBin
    C:Program Files (x86)Common FilesOracleJavajavapath
    C:Program Files (x86)InteliCLS Client
    C:Program FilesInteliCLS Client
    C:Windowssystem32
    C:Windows
    C:WindowsSystem32Wbem
    C:WindowsSystem32WindowsPowerShellv1.0
    C:Program Files (x86)NVIDIA CorporationPhysXCommon
    C:Program Files (x86)IntelIntel(R) Management Engine ComponentsDAL
    C:Program FilesIntelIntel(R) Management Engine ComponentsDAL
    C:Program Files (x86)IntelIntel(R) Management Engine ComponentsIPT
    C:Program FilesIntelIntel(R) Management Engine ComponentsIPT
    C:WINDOWSsystem32
    C:WINDOWS
    C:WINDOWSSystem32Wbem
    C:WINDOWSSystem32WindowsPowerShellv1.0
    C:WINDOWSSystem32OpenSSH
    C:Program FilesGitcmd
    C:Program Filesdotnet
    C:Program FilesPuTTY
    C:UsersKubaAppDataLocalProgramsPythonPython37Scripts
    C:UsersKubaAppDataLocalProgramsPythonPython37
    C:UsersKubaAppDataLocalMicrosoftWindowsApps
    C:UsersKubaAppDataLocalProgramsMicrosoft VS Codein
    C:UsersKubaAppDataLocalGitHubDesktopin
    %USERPROFILE%AppDataLocalMicrosoftWindowsApps

    C:UsersKubaAppDataLocalProgramsPythonPython37libsite-packages
umpy.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

推荐答案

试试 kaleido,它对我有用.它是虎鲸的替代品

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

conda install -c plotly python-kaleido