我尝试导入袖扣,代码如下:
from textblob import TextBlob
from wordcloud import WordCloud, STOPWORDS
import chart_studio.plotly as py
import plotly.graph_objs as go
from plotly.offline import iplot
import cufflinks
cufflinks.go_offline()
cufflinks.set_config_file(world_readable=True, theme='pearl', offline=True)但它返回的错误如下所示:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-7-4cccab8ca8ac> in <module>
5 import plotly.graph_objs as go
6 from plotly.offline import iplot
----> 7 import cufflinks
8 cufflinks.go_offline()
9 cufflinks.set_config_file(world_readable=True, theme='pearl', offline=True)
~\Anaconda3\lib\site-packages\cufflinks\__init__.py in <module>
17
18 from .plotlytools import *
---> 19 from plotly.plotly import plot
20 from .colors import cnames, get_colorscale
21 from .utils import pp
ImportError: cannot import name 'plot' from 'plotly.plotly' (C:\Users\asus\Anaconda3\lib\site-packages\plotly\plotly\__init__.py)一开始,这是import plotly.plotly as py代码中的一个错误,它说密图已被弃用,并建议我使用chart_studio.plotly。因此,我更改了代码,它可以工作,但import cufflinks仍然是错误的。有谁可以帮我?
发布于 2019-09-22 12:11:18
This solution来自一个打开的问题,来自袖珍链接源码页面。基本上,您的Jupyter Notebook抛出了一个错误,因为即使在安装了chart_studio之后,源代码也没有更新。
要解决此问题,请转到包含cufflink源代码的目录。在您的例子中,它应该是\Anaconda3\lib\site-packages\cufflinks。在该目录中,找到三个文件,即:_init_.py、plotlytools.py和tools.py。在每个文件中,将"plotly.plotly“更改为"chart_studio.plotly”并保存文件。尝试再次运行导入。
这个来自plotly社区的post可能也会有帮助!请注意,这篇文章实际上将你重定向到最初打开的问题。
如果你熟悉Github PR,these are建议的提交(虽然还没有合并..)
https://stackoverflow.com/questions/57634498
复制相似问题