tensorflow: Mac + Python 3.6.1: Attempting to download mnist data results in CERTIFICATE_VERIFY_FAILED error
System information
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow): No
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Mac OS X 10.12.5
- TensorFlow installed from (source or binary): binary
- TensorFlow version (use command below): v1.2.0-rc2-21-g12f033d 1.2.0
- Bazel version (if compiling from source): n/a
- CUDA/cuDNN version: none
- GPU model and memory: n/a
- Exact command to reproduce:
$ python3 --version
Python 3.6.1
$ python3 -m virtualenv venv
Using base prefix '/Library/Frameworks/Python.framework/Versions/3.6'
New python executable in .../venv/bin/python3
Also creating executable in .../venv/bin/python
Installing setuptools, pip, wheel...done.
$ source venv/bin/activate
$ pip install tensorflow
Collecting tensorflow
Using cached tensorflow-1.2.0-cp36-cp36m-macosx_10_11_x86_64.whl
....
$ python
Python 3.6.1 (v3.6.1:69c0db5050, Mar 21 2017, 01:21:04)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from tensorflow.examples.tutorials.mnist import input_data
>>> mnist = input_data.read_data_sets("/tmp/data/")
Traceback (most recent call last):
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:749)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File ".../venv/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py", line 235, in read_data_sets
SOURCE_URL + TRAIN_IMAGES)
File ".../venv/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/base.py", line 208, in maybe_download
temp_file_name, _ = urlretrieve_with_retry(source_url)
File ".../venv/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/base.py", line 165, in wrapped_fn
return fn(*args, **kwargs)
File ".../venv/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/base.py", line 190, in urlretrieve_with_retry
return urllib.request.urlretrieve(url, filename)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 248, in urlretrieve
with contextlib.closing(urlopen(url, data)) as fp:
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 526, in open
response = self._open(req, data)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 544, in _open
'_open', req)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1361, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1320, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)>
This doesn’t reproduce with TensorFlow 1.1.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 23
- Comments: 31 (2 by maintainers)
This might have also been because I recently switched to a new machine and it’s still only partially installed 😃
For future reference: if you want to use the Python dmg installer, you also have to read Python 3’s ReadMe and run the
/Applications/Python 3.6/Install Certificates.commandbash script to install newer certs.Thanks for the quick response, @aselle!
If you want to just copy paste into Terminal:
/Applications/Python\ 3.6/Install\ Certificates.command@brightbytes-dude Did you run the command listed here: https://github.com/tensorflow/tensorflow/issues/10779#issuecomment-309134512
/Applications/Python\ 3.6/Install\ Certificates.commandCould you please change the MNIST download URL in contrib/learn/python/learn/datasets/mnist.py to not use https ? That will help people who are having this problem. In tried in a browser and the http download link works.
line to change: SOURCE_URL = ‘https://storage.googleapis.com/cvdf-datasets/mnist/’ new line: SOURCE_URL = ‘https://storage.googleapis.com/cvdf-datasets/mnist/’
I have same problem with ssl and this line fix it, /Applications/Python\ 3.6/Install\ Certificates.command thanks @EthanAI @aselle @paulcwatts
on MacOS
/Applications/Python\ 3.6/Install\ Certificates.commandcommand works for meHere’s what worked for me:
That’s all. The keras download utility looks in that folder for cached data before going over the network.
(Python 3.7.3, tensorflow 2.1.0)
It worked for me.
I see both the urls are same.