Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python SSL Certification Problems in Tensorflow

I'm trying to download the MNIST data which is supposedly handled in:

tensorflow.examples.tutorials.mnist.input_data.read_data_sets()

As far as I'm aware read_data_sets sends a pull request to a server to download the (approx.) 1.5GB of data.

I keep getting this traceback error:

File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py",
line 1318, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))   File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py",
line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)   File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py",
line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)   File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py",
line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)   File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py",
line 1026, in _send_output
    self.send(msg)   File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py",
line 964, in send
    self.connect()   File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py",
line 1400, in connect
    server_hostname=server_hostname)   File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py",
line 401, in wrap_socket
    _context=self, _session=session)   File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py",
line 808, in __init__
    self.do_handshake()   File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py",
line 1061, in do_handshake
    self._sslobj.do_handshake()   File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py",
line 683, in do_handshake
    self._sslobj.do_handshake() ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)

It obviously has something to do with the SSL cert python uses... so I went to /Applications/Python 3.6/ and executed the "Install Certifactions.command" located there and got this error:

Traceback (most recent call last):   File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/shutil.py",
line 544, in move
    os.rename(src, real_dst) PermissionError: [Errno 13] Permission denied:
'/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/certifi-2015.04.28.dist-info/DESCRIPTION.rst'
-'/var/folders/mq/g_jy_1qx1vjdb3xmdh7y62y80000gn/T/pip-3m8ixnf5-uninstall/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/certifi-2015.04.28.dist-info/DESCRIPTION.rst'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):   File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/basecommand.py",
line 215, in main
    status = self.run(options, args)   File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/commands/install.py",
line 342, in run
    prefix=options.prefix_path,   File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/req/req_set.py",
line 778, in install
    requirement.uninstall(auto_confirm=True)   File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/req/req_install.py",
line 754, in uninstall
    paths_to_remove.remove(auto_confirm)   File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/req/req_uninstall.py",
line 115, in remove
    renames(path, new_path)   File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/utils/__init__.py",
line 267, in renames
    shutil.move(old, new)   File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/shutil.py",
line 559, in move
    os.unlink(src) PermissionError: [Errno 13] Permission denied: '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/certifi-2015.04.28.dist-info/DESCRIPTION.rst'

Is there something wrong with my filesystem permissions? I quite literally reinstalled OSX about a month ago on this computer...

Is there a way I can manually install the certs? Or issue the pull request to download the data to a non-https address?

like image 631
jmkmay Avatar asked Oct 20 '17 23:10

jmkmay


People also ask

What SSL certificates does Python use?

By default, the Python ssl module uses the system CA certificate bundle - /etc/pki/tls/certs/ca-bundle.


2 Answers

Install certificates, either double-clicking the file in /Applications/Python 3.6/Install Certificates.command (on macOS), or running this command from a bash terminal:

/Applications/Python\ 3.6/Install\ Certificates.command

And now the certificates are installed to download the data over HTTPS.

Source: dedicated issue on TensorFlow GitHub for official models.

like image 135
miguelmorin Avatar answered Nov 14 '22 22:11

miguelmorin


replacing https with http got it running

In contrib/learn/python/learn/datasets/mnist.py edit the line with SOURCE_URL='http://storage.googleapis.com/cvdf-datasets/mnist/'

like image 32
Jiss Raphel Avatar answered Nov 14 '22 21:11

Jiss Raphel