Базовая гистограмма с сюжетом

Я пытаюсь сделать гистограмму, с этим кодом

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'] = False -> 151 url = plot(figure_or_data, **plot_options) 152 153 если isinstance (figure_or_data, dict):

C:\Users\Demonstrator\Anaconda3\lib\site-packages\plotly\plotly\plotly.py

in plot (figure_or_data, validate, ** plot_options) 239 240 plot_options = _plot_option_logic (plot_options) -> 241 res = _send_to_plotly(figure, **plot_options) 242 если res['error'] == '': 243 если plot_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 username = credentials['username'] 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 повысить исключения.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.

Любая идея, чтобы помочь мне, пожалуйста?

Спасибо

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, он не совпадает с вашим паролем.

Другие вопросы по тегам