找不到模块错误:没有名为“chart_studio”的模块

Mil*_*s M 8 python pip plotly jupyter-notebook

!pip install chart_studio在 jupyter notebook 中运行。

然后在运行此代码时:

import numpy as np
import pandas as pd

import cufflinks as cf
import chart_studio.plotly as py

from chart_studio.plotly import iplot

import plotly.graph_objects as go
chart_studio.tools.set_credentials_file(username=xx, api_key = xxx)
Run Code Online (Sandbox Code Playgroud)

我回来了:

No module named 'chart_studio'

我尝试过语法更正,但没有任何乐趣。有什么建议?

小智 6

只是pip install chart_studio在现在的环境下


小智 1

import chart_studio.plotly as py
Run Code Online (Sandbox Code Playgroud)

在上面的行中,您已将 Chart_studio 导入为 py. 所以,

chart_studio.tools.set_credentials_file(username=xx, api_key = xxx)
Run Code Online (Sandbox Code Playgroud)

在这一行中,您需要通过别名进行调用

py.tools.set_credentials()
Run Code Online (Sandbox Code Playgroud)

否则,您可以导入chart_studio.plotly并直接使用它。如有疑问请评论。