ImportError: The plotly.plotly module is deprecated,please install the chart-studio

ImportError: The plotly.plotly module is deprecated,please install the chart-studio package and use the chart_studio.plotly module instead. 

问题:

plotly原有api过期了

import plotly.plotly as py
import cufflinks as cf
import pandas as pd

cf.set_config_file(offline=True, theme='ggplot')


N = 500
x = np.linspace(0, 1, N)
y = np.random.randn(N)
df = pd.DataFrame({'x': x, 'y': y})
df.set_index('x',inplace=True)

df.iplot(kind='scatter', filename='tmp/cf_line.html')


解决:

#安装

pip install chart-studio

#导入

from chart_studio import plotly

ImportError: The plotly.plotly module is deprecated,please install the chart-studio

from chart_studio import plotly as py
import cufflinks as cf
import pandas as pd
import numpy as np

cf.set_config_file(offline=True, theme='ggplot')


N = 500
x = np.linspace(0, 1, N)
y = np.random.randn(N)
df = pd.DataFrame({'x': x, 'y': y})
df.set_index('x',inplace=True)

df.iplot(kind='scatter', filename='cf_line.html')

完整错误日志

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-235d2cc141ff> in <module>
----> 1 import plotly.plotly as py
      2 import cufflinks as cf
      3 import pandas as pd
      4 
      5 cf.set_config_file(offline=True, theme='ggplot')

D:\anaconda\lib\site-packages\plotly\plotly\__init__.py in <module>
      2 from _plotly_future_ import _chart_studio_error
      3 
----> 4 _chart_studio_error("plotly")

D:\anaconda\lib\site-packages\_plotly_future_\__init__.py in _chart_studio_error(submodule)
     47 chart_studio.{submodule} module instead.
     48 """.format(
---> 49             submodule=submodule
     50         )
     51     )

ImportError: 
The plotly.plotly module is deprecated,
please install the chart-studio package and use the
chart_studio.plotly module instead. 

参考:How do I fix a deprecated module for plotly.plotly

上一篇:24常用注解总结


下一篇:【NodeJs】nodejs非安装版(Windows)的环境变量配置 全过程