属性错误:模块 ‘plotly.tools’ 没有属性 ‘set_credentials_file’

huangapple go评论82阅读模式
英文:

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/.

huangapple
  • 本文由 发表于 2023年7月27日 18:02:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/76778624.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定