【问题标题】:Basic Bar Chart with plotly带有 plotly 的基本条形图
【发布时间】: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.

有什么好办法帮帮我吗?

谢谢

【问题讨论】:

    标签: python plot plotly


    【解决方案1】:

    您需要注意错误中的回溯。在这种情况下,它比平时更有帮助。解决方法在这里给你:

    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. 
    

    因此,在您尝试制作情节之前,请输入您在注册该网站时使用的凭据。您可能需要登录网络浏览器并请求生成 API 密钥,它与您的密码不同。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-07
      • 1970-01-01
      • 2021-12-28
      • 2021-11-11
      • 1970-01-01
      • 2021-11-10
      • 1970-01-01
      • 2016-02-25
      相关资源
      最近更新 更多