我试着用下面的代码做一个条形图
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')
但我发现了一个错误:
C:\Users\Demonstrator\Anaconda3\lib\site-packages\plotly\plotly\plotly.py中的PlotlyLocalCredentialsError跟踪(最近一次调用)在() 3 y=20,14,23 4 )] -->5 py.iplot(data,filename=‘basic’) 在dict(figure_or_data,**plot_options) 149中,如果'auto_open‘不在plot_options: 150个auto_open_options’‘auto_open’= False --151个url =plot_options(figure_or_data,**plot_options) 152如果是isinstance(figure_or_data,dict): C:\Users\Demonstrator\Anaconda3\lib\site-packages\plotly\plotly\plotly.py 在图(figure_or_data,‘auto,**plot_options) 239 240 plot_options = _plot_option_logic(plot_options) --> 241 res =_send_to_plotly(图,**plot_options) 242中,如果res’**plot_options‘错误:243个plot_options_plot_options_options’‘auto_open’: C:\Users\Demonstrator\Anaconda3\lib\site-packages\plotly\plotly\plotly.py 在_send_to_plotly(图,**plot_options) 1401 cls=utils.PlotlyJSONEncoder中,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 api_key = credentials.get('api_key') 1351中,如果没有用户名或没有api_key:-> 1352引发exceptions.PlotlyLocalCredentialsError() 1353 1354 PlotlyLocalCredentialsError:无法在本地机器上为您找到“用户名”、“api-key”对。要暂时登录(直到停止运行Python),运行:>>> import plotly.plotly as py >>> py.sign_in('username','api_key')更好,使用'tools‘模块:>>> import plotly.tools as tls >>> tls.set_credentials_file(username='username',api_key=’api_key‘)永久保存凭据以获得更多帮助,请参见https://plot.ly/python。
能帮我个忙吗?
谢谢
发布于 2016-08-29 14:37:06
您需要注意错误中的跟踪。在这种情况下,它甚至比平常更有帮助。这里给出了解决办法:
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.
因此,在尝试制作一个情节之前,请输入您在注册该网站时使用的凭据。您可能需要在web浏览器中登录并请求生成API密钥,这与您的密码不一样。
https://stackoverflow.com/questions/39208680
复制相似问题