Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

Python SSL error

Dear all,

I’m using Python 2.7.10 via the Spyder IDE. I’m trying to run the following Plotly code (taken from here:

import plotly.plotly as py
from import FigureFactory as FF 

data_matrix = [['Country', 'Year', 'Population'],
               ['United States', 2000, 282200000],
               ['Canada', 2000, 27790000],
               ['United States', 2005, 295500000],
               ['Canada', 2005, 32310000],
               ['United States', 2010, 309000000],
               ['Canada', 2010, 34000000]]

table = FF.create_table(data_matrix)
py.iplot(table, filename='simple_table')

I have also configured my username and API-key from my Plotly account. Sadly, I get the following error (SSL related);

requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)

The full error is given below. Does anyone know how to solve this?

>>> runfile('C:/Users/j079/Desktop/', wdir='C:/Users/j079/Desktop')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\", line 685, in runfile
    execfile(filename, namespace)
  File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\", line 71, in execfile
    exec(compile(scripttext, filename, 'exec'), glob, loc)
  File "C:/Users/j079/Desktop/", line 20, in <module>
    py.iplot(table, filename='simple_table')
  File "C:\Python27\lib\site-packages\plotly-1.12.3-py2.7.egg\plotly\plotly\", line 151, in iplot
    url = plot(figure_or_data, **plot_options)
  File "C:\Python27\lib\site-packages\plotly-1.12.3-py2.7.egg\plotly\plotly\", line 241, in plot
    res = _send_to_plotly(figure, **plot_options)
  File "C:\Python27\lib\site-packages\plotly-1.12.3-py2.7.egg\plotly\plotly\", line 1426, in _send_to_plotly
  File "C:\Python27\lib\site-packages\requests\", line 109, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "C:\Python27\lib\site-packages\requests\", line 50, in request
    response = session.request(method=method, url=url, **kwargs)
  File "C:\Python27\lib\site-packages\requests\", line 465, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Python27\lib\site-packages\requests\", line 573, in send
    r = adapter.send(request, **kwargs)
  File "C:\Python27\lib\site-packages\requests\", line 431, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)

Hey Max –

Hm, I haven’t seen that before. Are you working behind a proxy by chance?
Or is there anything else that might be abnormal in your network

Extremely late to the party, but I am going to leave here a hotfix in case anyone else gets the same error…

The error is mostly due to a self-signing of the certificate passed to the request module, most likely due to some corporate proxy setting.

In this case, what can be done is download the root certificate of manually (you can do that from google chrome by clicking on the “Secure” icon:


Once you have downloaded the certificate, you have to point to it.

To my knowledge, you cannot access the requests session that gets created by plotly. If that were possible, you could do session.verify=‘path_to_cert’ and solve the issue.

In absence of that, you can set up an environment variable which will be accessed by requests by default. It’s messier but gets the job done:

import os
os.environ[‘REQUESTS_CA_BUNDLE’] = ‘path to cer’

If you do this, you should be able to successfully pass SSL verification and the problem should go away.

1 Like