【发布时间】:2016-08-29 14:27:13
【问题描述】:
我尝试用这段代码做一个条形图
import plotly.plotly as py
import plotly.graph_objs as go
data = [go.Bar(
x=['giraffes', 'orangutans', 'monkeys'],
y=[20, 14, 23]
)]
py.iplot(data, filename='basic-bar')
但我得到了这个错误:
PlotlyLocalCredentialsError Traceback (most recent call last) <ipython-input-42-9eae40f28f37> in <module>() 3 y=[20, 14, 23] 4 )] ----> 5 py.iplot(data, filename='basic-bar') C:\Users\Demonstrator\Anaconda3\lib\site-packages\plotly\plotly\plotly.py在 iplot(figure_or_data, **plot_options) 149如果'auto_open'不在plot_options中: 150 plot_options ['auto_open'] = 假 --> 151 url = plot(figure_or_data, **plot_options) 152 153 if isinstance(figure_or_data, dict):
C:\Users\Demonstrator\Anaconda3\lib\site-packages\plotly\plotly\plotly.py在情节中(图或数据,验证,**情节选项) 239 第240章 --> 241 res = _send_to_plotly(图,**plot_options) 242如果res ['错误'] =='': 第243章
C:\Users\Demonstrator\Anaconda3\lib\site-packages\plotly\plotly\plotly.py在_send_to_plotly(图,**plot_options) 第1401章 1402 凭证 = get_credentials() -> 1403 validate_credentials(凭证) 1404 用户名 = 凭据 ['用户名'] 1405 api_key = 凭据['api_key']
C:\Users\Demonstrator\Anaconda3\lib\site-packages\plotly\plotly\plotly.py在 validate_credentials(凭证)中 第1350章 1351 如果不是用户名或不是 api_key: -> 1352 引发异常。PlotlyLocalCredentialsError() 1353 第1354章
PlotlyLocalCredentialsError: Couldn't find a 'username', 'api-key' pair for you on your local machine. To sign in temporarily (until you stop running Python), run: >>> import plotly.plotly as py >>> py.sign_in('username', 'api_key') Even better, save your credentials permanently using the 'tools' module: >>> import plotly.tools as tls >>> tls.set_credentials_file(username='username', api_key='api-key') For more help, see https://plot.ly/python.
有什么好办法帮帮我吗?
谢谢
【问题讨论】: