Python plotly登录错误

Python Plotly sign in error

我在使用 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://whosebug.com/questions/tagged/plotly'>Stack Overflow channel.

我认为 plotly 在我的本地机器上没有正确设置,但无法找到解决此问题的正确方法。我正在使用来自 Anaconda3 的 spyder,并且在 windows7.

有人可以帮我解决这个问题吗?谢谢!

您在顶部使用 myapikey,在登录时使用 mypassword。在两个地方使用相同的变量。