Basic Bar Chart with plotly
<p>I try to do a bar charts, with this code </p>

<pre><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')
</code></pre>

<p>But I got this error : </p>

<blockquote>
<pre><code>PlotlyLocalCredentialsError               Traceback (most recent call last)
&lt;ipython-input-42-9eae40f28f37&gt; in &lt;module&gt;()
      3             y=[20, 14, 23]
      4     )]
----&gt; 5 py.iplot(data, filename='basic-bar')

C:\Users\Demonstrator\Anaconda3\lib\site-packages\plotly\plotly\plotly.py
</code></pre>
  
  <p>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):</p>

<pre><code>C:\Users\Demonstrator\Anaconda3\lib\site-packages\plotly\plotly\plotly.py
</code></pre>
  
  <p>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']:</p>

<pre><code>C:\Users\Demonstrator\Anaconda3\lib\site-packages\plotly\plotly\plotly.py
</code></pre>
  
  <p>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']</p>

<pre><code>C:\Users\Demonstrator\Anaconda3\lib\site-packages\plotly\plotly\plotly.py
</code></pre>
  
  <p>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 </p>

<pre><code>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:
&gt;&gt;&gt; import plotly.plotly as py
&gt;&gt;&gt; py.sign_in('username', 'api_key')

Even better, save your credentials permanently using the 'tools' module:
&gt;&gt;&gt; import plotly.tools as tls
&gt;&gt;&gt; tls.set_credentials_file(username='username', api_key='api-key')

For more help, see https://plot.ly/python.
</code></pre>
</blockquote>

<p>Any idea to help me please?</p>

<p>Thank you</p>

<p>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:</p>

<pre><code>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:
&gt;&gt;&gt; import plotly.plotly as py
&gt;&gt;&gt; py.sign_in('username', 'api_key')

Even better, save your credentials permanently using the 'tools' module:
&gt;&gt;&gt; import plotly.tools as tls
&gt;&gt;&gt; tls.set_credentials_file(username='username', api_key='api-key')

For more help, see https://plot.ly/python. 
</code></pre>

<p>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.</p>

python plot plotly