嗨,我正尝试在完全脱机时使用 plotly 。这实际上意味着,如果需要对Internet服务进行任何类型的请求,它们将无法通过:
我正在使用非常简单的导入方式开始工作:
from plotly import __version__
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
print __version__ # requires version >= 1.9.0
每次,无论我尝试什么,我总是收到相同的错误消息:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-12-dd44b8cf2e22> in <module>
----> 1 from plotly import __version__
2 from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
3
4 print(__version__) # requires version >= 1.9.0
~/anaconda3/lib/python3.7/site-packages/plotly/__init__.py in <module>
29 from __future__ import absolute_import
30
---> 31 from plotly import (plotly, dashboard_objs, graph_objs, grid_objs, tools,
32 utils, session, offline, colors, io)
33 from plotly.version import __version__
~/anaconda3/lib/python3.7/site-packages/plotly/plotly/__init__.py in <module>
8
9 """
---> 10 from . plotly import (
11 sign_in,
12 update_plot_options,
~/anaconda3/lib/python3.7/site-packages/plotly/plotly/plotly.py in <module>
29
30 from plotly import exceptions, files, session, tools, utils
---> 31 from plotly.api import v1, v2
32 from plotly.basedatatypes import BaseTraceType, BaseFigure, BaseLayoutType
33 from plotly.plotly import chunked_requests
~/anaconda3/lib/python3.7/site-packages/plotly/api/v1/__init__.py in <module>
1 from __future__ import absolute_import
2
----> 3 from plotly.api.v1.clientresp import clientresp
~/anaconda3/lib/python3.7/site-packages/plotly/api/v1/clientresp.py in <module>
7
8 from plotly import config, utils, version
----> 9 from plotly.api.v1.utils import request
10
11
~/anaconda3/lib/python3.7/site-packages/plotly/api/v1/utils.py in <module>
3 import requests
4 from requests.exceptions import RequestException
----> 5 from retrying import retry
6
7 from plotly import config, exceptions
ModuleNotFoundError: No module named 'retrying'
我不确定是否有任何理由让我烦恼安装“重试”,或者是否根本没有办法让“密谋”完全脱机工作。至少,离线会产生误导作用-它们可能会与无用之类的东西配合使用。
答案 0 :(得分:0)
以下是有关如何离线使用Plot的示例。
from plotly.offline import plot as off
import plotly.figure_factory as ff
import plotly.io as pio
table = ff.create_table(df, index=True)
fig = off(table, filename='simple_table')
pio.write_image(table, 'sample.png')
我还没有找到任何在线可用的绘图功能,这些功能也无法离线使用。
PS。我相信这需要plotly-orca。 https://github.com/plotly/orca
检查您的Plotly版本,离线打印需要1.9.4+版本。
plotly.offline.iplot
用于jupyter,plotly.offline.plot
用于创建独立的HTML,该HTML保存在本地并在Web浏览器中打开。