Basic Bar Chart with plotly
Question: I try to do a bar charts, with this code

    
    
    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')
    

But I got this error :

>
>     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
>  
>
> in iplot(figure_or_data, **plot_options) 149 if 'auto_open' not in
> plot_options: 150 plot_options['auto_open'] = False \--> 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
>  
>
> 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 if res['error'] == '': 243 if plot_options['auto_open']:
>  
>  
>     C:\Users\Demonstrator\Anaconda3\lib\site-
> packages\plotly\plotly\plotly.py
>  
>
> in _send_to_plotly(figure, **plot_options) 1401 cls=utils.PlotlyJSONEncoder)
> 1402 credentials = get_credentials() -> 1403
> validate_credentials(credentials) 1404 username = credentials['username']
> 1405 api_key = credentials['api_key']
>  
>  
>     C:\Users\Demonstrator\Anaconda3\lib\site-
> packages\plotly\plotly\plotly.py
>  
>
> in validate_credentials(credentials) 1350 api_key =
> credentials.get('api_key') 1351 if not username or not api_key: -> 1352
> raise exceptions.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.
>  

Any idea to help me please?

Thank you


Answer: You need to pay attention to the traceback in the error. In this case, it's
even more helpful than usual. The solution is given to you here:

    
    
    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. 
    

So, enter your credentials used when you signed up to the site before you
attempt to make a plot. You may have to sign in in a web browser and request
for an API key to be generated, it is not the same as your password.

