其他分享
首页 > 其他分享> > ImportError: The plotly.plotly module is deprecated,please install the chart-studio

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

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

标签:ImportError,deprecated,chart,module,cf,studio,plotly,import
来源: https://blog.csdn.net/zhongkeyuanchongqing/article/details/119302198