[英]Plotly.io doesn't see the psutil package even though it's installed
I'm trying to execute the following code:我正在尝试执行以下代码:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
%matplotlib inline
import seaborn as sns
import plotly.graph_objects as go
from plotly.offline import init_notebook_mode, iplot
init_notebook_mode(connected=True)
from sklearn.preprocessing import QuantileTransformer
import os
if not os.path.exists("images"):
os.mkdir("images")
# import orca
import plotly.io as pio
pio.orca.config.executable = '/path/to/orca'
pio.orca.ensure_server()
import psutil
To which I get:我得到:
ValueError Traceback (most recent call last)
<ipython-input-89-6e2b31e44303> in <module>
25 import plotly.io as pio
26 pio.orca.config.executable = '/path/to/orca'
---> 27 pio.orca.ensure_server()
28
29 import psutil
~/Library/Python/3.7/lib/python/site-packages/plotly/io/_orca.py in ensure_server()
1368 Install using conda:
1369 $ conda install psutil
-> 1370 """
1371 )
1372
ValueError: Image generation requires the psutil package.
Install using pip:
$ pip install psutil
Install using conda:
$ conda install psutil
The package is installed, I reinstalled it just in case as well but keep getting the error. package 已安装,我重新安装它以防万一,但一直出现错误。
The end goal is to be able to safe plotly generated images automatically with fig.write_image("images/fig1.png")
最终目标是能够使用
fig.write_image("images/fig1.png")
自动保护 plotly 生成的图像
If you want to save the plotly figure as image.如果要将 plotly 图保存为图像。
What worked for me was to install kaleido
and then use the kaleido engine eg对我有用的是安装
kaleido
,然后使用万花筒引擎,例如
pip install Kaleido plotly.io.write_image(fig, 'fig1.jpeg', format='jpeg',validate=False, engine='kaleido') pip 安装 Kaleido plotly.io.write_image(fig, 'fig1.jpeg', format='jpeg',validate=False, engine='kaleido')
see the following question/answer too: How to save plotly express plot into a html or static image file?请参阅以下问题/答案: 如何将 plotly express plot 保存到 html 或 ZA81259CEF8E959C6294EDF1 图像文件中?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.