英文:
AttributeError: module 'plotly.tools' has no attribute 'set_credentials_file'
问题
我正在遵循一个关于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'
我在Stack Overflow上看到的其他问题都是几年前的,我担心包的文档已经更新了。
有人可以帮忙吗?
英文:
I am following an introduction tutorial for plotly and I am facing a problem, using Jupyter.
This is the code below:
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")
And the error I am getting.
--------------------------------------------------------------------
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'
All the other questions I am seeing on SO are from some years ago and I am afraid the documentation of the package is updated.
Can someone help?
答案1
得分: 3
如@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/。
英文:
As it was mentioned by @Sotos in the comment, the set_credentials_file file is no longer available in plotly.tools.
You should use the chart_studio instead: https://pypi.org/project/chart-studio/ and it should work for you:
import chart_studio.tools as tls
tls.set_credentials_file(username='xxx', api_key='yyyy')
Also have a look at the current Getting Started doc: https://plotly.com/python/getting-started-with-chart-studio/.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论