Python Plotly登录

2024-09-28 17:28:10 发布

您现在位置:Python中文网/ 问答频道 /正文

使用plotly绘制图表时收到错误消息。我的代码如下:

import plotly as py
py.tools.set_credentials_file(username='myaccount', api_key='myapikey')

import plotly.plotly as py
import plotly.tools as plotly_tools
from plotly.graph_objs import *

py.sign_in("myaccount", "mypassword")

(Some code that is not related to this problem.)

py.iplot(data, filename='apple stock moving average')

错误消息是:

Traceback (most recent call last):

File "", line 1, in py.iplot(data, filename='apple stock moving average')

File "C:\Anaconda3\lib\site-packages\plotly\plotly\plotly.py", line 151, in iplot url = plot(figure_or_data, **plot_options)

File "C:\Anaconda3\lib\site-packages\plotly\plotly\plotly.py", line 241, in plot res = _send_to_plotly(figure, **plot_options)

File "C:\Anaconda3\lib\site-packages\plotly\plotly\plotly.py", line 1404, in _send_to_plotly raise exceptions.PlotlyError(r['error'])

PlotlyError: Aw, snap! You tried to use our API as the user 'myaccount', but the supplied API key doesn't match our records. You can view your API key at plot.ly/settings.

You're most likely getting this message because your local credentials file isn't synced with the Plotly server you're communicating with.

Go to plot.ly//getting-started (e.g., plot.ly/python/getting-started) for more information.

Make sure that you're logged in as myaccount.

Need help? Please try searching Plotly's http://stackoverflow.com/questions/tagged/plotly'>Stack Overflow channel.

我认为plotly在本地计算机上的设置不正确,但无法找到解决此问题的正确方法。我正在使用水蟒3的spyder,它在windows7下。

有人能帮我吗?谢谢!


Tags: tokeyinpyimportdataplotas