我正在遵循plotly的介绍教程,但在使用Jupyter时遇到了问题。
这是下面的代码:
import numpy as np
import pandas as pd
import cufflinks as cf
import chart_studio.plotly as py
import plotly.tools as tls
import plotly.graph_objs as go
tls.set_credentials_file(username = "xxx", api_key = "yyyy")
以及我收到的错误。
--------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[21], line 1
----> 1 tls.set_credentials_file(username = "xxxx", api_key = "yyy")
AttributeError: module 'plotly.tools' has no attribute 'set_credentials_file'
我在 SO 上看到的所有其他问题都是几年前的,我担心软件包的文档已更新。
有人可以帮忙吗?
最佳答案
正如 @Sotos 在评论中提到的,set_credentials_file 文件在 plotly.tools 中不再可用。
您应该使用chart_studio:https://pypi.org/project/chart-studio/它应该适合你:
import chart_studio.tools as tls
tls.set_credentials_file(username='xxx', api_key='yyyy')
另请查看当前的入门文档:https://plotly.com/python/getting-started-with-chart-studio/ .
关于python - 属性错误: module 'plotly.tools' has no attribute 'set_credentials_file' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76778624/