$ 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)>
Esto no se reproduce con TensorFlow 1.1.
¿Podrías probar con python2 (instalación predeterminada del sistema de py)? Además, ¿cómo se instaló con brew o macports (usamos brew para nuestras pruebas, por lo que es más probable que funcione)?
Instalé Python 3.6 usando el instalador dmg del sitio web de Python (no a través de brew o macports).
Parece funcionar con Python 2.7.10. Pensé que en Python 2.x urlretrieve no validaba el certificado del servidor, pero aparentemente lo hace a partir de 2.7.9: https://docs.python.org/2/library/urllib.html
Me funciona en Python 3.4 en Linux. Intentaría instalar python3.6 usando brew. Podría ser que la distribución python3 que está utilizando no tenga certificados de datos.
Esto también podría deberse a que recientemente cambié a una nueva máquina y todavía está parcialmente instalada :)
Para referencia futura: si desea utilizar el instalador dmg de Python, también debe leer el archivo Léame de Python 3 y ejecutar el script /Applications/Python 3.6/Install Certificates.command
bash para instalar certificados más nuevos.
¡Gracias por la rápida respuesta, @aselle!
Si solo desea copiar y pegar en la Terminal:
/Applications/Python\ 3.6/Install\ Certificates.command
Recibo exactamente el mismo problema en MacOSX 10.11.6
Primero seguí exactamente los pasos aquí para la configuración virtualenv
para Python 3.n: https://www.tensorflow.org/install/install_mac
Luego, siguiendo los primeros 2 pasos de este tutorial https://www.tensorflow.org/get_started/mnist/beginners , veo lo siguiente; Cualquier sugerencia para solucionar esto (por ejemplo, ¿podría descargar esto de otro lugar?) sería muy apreciada.
(tensorflow) ~/tensorflow $ python
Python 3.6.2 (v3.6.2:5fd33b5926, Jul 16 2017, 20:11:06)
[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("MNIST_data/", one_hot=True)
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:748)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/aaron/tensorflow/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py", line 235, in read_data_sets
SOURCE_URL + TRAIN_IMAGES)
File "/Users/aaron/tensorflow/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 "/Users/aaron/tensorflow/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/base.py", line 165, in wrapped_fn
return fn(*args, **kwargs)
File "/Users/aaron/tensorflow/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:748)>
@ brightbytes-dude ¿Ejecutó el comando que se enumera aquí: https://github.com/tensorflow/tensorflow/issues/10779#issuecomment -309134512
/Applications/Python\ 3.6/Install\ Certificates.command
Eso hizo el truco, gracias !! (Asumí estúpidamente que solo era relevante para la instalación dmg
).
¿Podría cambiar la URL de descarga de MNIST en contrib / learn / python / learn / datasets / mnist.py para no usar https? Eso ayudará a las personas que tienen este problema. Lo probé en un navegador y el enlace de descarga http funciona.
línea para cambiar:
SOURCE_URL = ' https://storage.googleapis.com/cvdf-datasets/mnist/ '
nueva línea:
SOURCE_URL = ' https://storage.googleapis.com/cvdf-datasets/mnist/ '
Hola,
Soy nuevo en Python y Tensorflow. Probar el ejemplo de MNIST y recibir los mismos mensajes de error que paulcwatts (arriba)
de tensorflow.examples.tutorials.mnist importar input_data
mnist = input_data.read_data_sets ("MNIST_data /", one_hot = True)
Rastreo (llamadas recientes más última):
Archivo "C: UsersAndreasDocumentsPythonliburllibrequest.py", línea 1318, en do_open
encode_chunked = req.has_header ('Transferencia-codificación'))
Archivo "C: UsersAndreasDocumentsPythonlibhttpclient.py", línea 1239, en solicitud
self._send_request (método, url, cuerpo, encabezados, encode_chunked)
Archivo "C: UsersAndreasDocumentsPythonlibhttpclient.py", línea 1285, en _send_request
self.endheaders (cuerpo, encode_chunked = encode_chunked)
Archivo "C: UsersAndreasDocumentsPythonlibhttpclient.py", línea 1234, en encabezados finales
self._send_output (cuerpo_mensaje, encode_chunked = encode_chunked)
Archivo "C: UsersAndreasDocumentsPythonlibhttpclient.py", línea 1026, en _send_output
self.send (mensaje)
Archivo "C: UsersAndreasDocumentsPythonlibhttpclient.py", línea 964, en enviar
self.connect ()
Archivo "C: UsersAndreasDocumentsPythonlibhttpclient.py", línea 1400, en connect
nombre_host_servidor = nombre_host_servidor)
Archivo "C: UsersAndreasDocumentsPythonlibssl.py", línea 401, en wrap_socket
_context = self, _session = sesión)
Archivo "C: UsersAndreasDocumentsPythonlibssl.py", línea 808, en __init__
self.do_handshake ()
Archivo "C: UsersAndreasDocumentsPythonlibssl.py", línea 1061, en do_handshake
self._sslobj.do_handshake ()
Archivo "C: UsersAndreasDocumentsPythonlibssl.py", línea 683, en do_handshake
self._sslobj.do_handshake ()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] falló la verificación del certificado (_ssl.c: 748)
Durante el manejo de la excepción anterior, se produjo otra excepción:
Rastreo (llamadas recientes más última): La principal diferencia es que estoy en WINDOWS 10 y no puedo encontrar el comando de certificados.
Expediente "
mnist = input_data.read_data_sets ("MNIST_data /", one_hot = True)
Archivo "C: UsersAndreasDocumentsPythonlibsite-packagestensorflowcontriblearnpythonlearndatasetsmnist.py", línea 240, en read_data_sets
source_url + TRAIN_IMAGES)
Archivo "C: UsersAndreasDocumentsPythonlibsite-packagestensorflowcontriblearnpythonlearndatasetsbase.py", línea 208, en maybe_download
temp_file_name, _ = urlretrieve_with_retry (source_url)
Archivo "C: UsersAndreasDocumentsPythonlibsite-packagestensorflowcontriblearnpythonlearndatasetsbase.py", línea 165, en wrap_fn
return fn (argumentos , * kwargs)
Archivo "C: UsersAndreasDocumentsPythonlibsite-packagestensorflowcontriblearnpythonlearndatasetsbase.py", línea 190, en urlretrieve_with_retry
return urllib.request.urlretrieve (url, nombre de archivo)
Archivo "C: UsersAndreasDocumentsPythonliburllibrequest.py", línea 248, en urlretrieve
con contextlib.closing (urlopen (url, data)) como fp:
Archivo "C: UsersAndreasDocumentsPythonliburllibrequest.py", línea 223, en urlopen
return opener.open (url, datos, tiempo de espera)
Archivo "C: UsersAndreasDocumentsPythonliburllibrequest.py", línea 526, abierto
respuesta = self._open (req, datos)
Archivo "C: UsersAndreasDocumentsPythonliburllibrequest.py", línea 544, en _open
'_open', req)
Archivo "C: UsersAndreasDocumentsPythonliburllibrequest.py", línea 504, en _call_chain
resultado = func (* args)
Archivo "C: UsersAndreasDocumentsPythonliburllibrequest.py", línea 1361, en https_open
context = self._context, check_hostname = self._check_hostname)
Archivo "C: UsersAndreasDocumentsPythonliburllibrequest.py", línea 1320, en do_open
subir URLError (err)
urllib.error.URLError:
Perdón por hacer "preguntas estúpidas", pero esos errores no "desaparecen".
Tengo el mismo problema con ssl y esta línea lo soluciona,
/ Aplicaciones / Python 3.6 / Instalar Certificados.command
gracias @EthanAI @aselle @paulcwatts
Si alguien se tropieza con esta página pero busca la respuesta para permitir Tensorflow Hub en Ubuntu, lo hice funcionar así:
# Directory where user certs can be stored
cd /usr/local/share/ca-certificates
# Below may require elevated permissions, such as sudo su
pip3 install --upgrade certifi # Installs a certificate file
# Move the installed cert to the place Ubuntu expects it
cp /home/ubuntu/.local/lib/python3.5/site-packages/certifi/cacert.pem .
# Convert it into the format Ubuntu expects
openssl x509 -in cacert.pem -inform pem -outform der -out cacert.crt
# Actually load the new cert into the OS
update-ca-certificates
Además de esto, alguna combinación mágica de configuración de mi proxy corporativo, reiniciar el kernel de la computadora portátil Jupyter y ejecutar TF Hub desde un script en la terminal en lugar de hacerlo desde una computadora portátil, eventualmente hizo que TF Hub funcionara tanto en la terminal como en la computadora portátil. .
ejecutar ese comando también falló.
./Instalar Certificados.command
- instalar pip - actualizar certifi
Recogiendo certifi
Error de deserialización de entrada de caché, entrada ignorada
No se pudo recuperar la URL https://pypi.python.org/simple/certifi/ : Hubo un problema al confirmar el certificado ssl: [SSL: CERTIFICATE_VERIFY_FAILED] verificación del certificado falló (_ssl.c: 777) - omitiendo
No se pudo encontrar una versión que cumpla con el requisito de certificación (de las versiones :)
No se encontró distribución coincidente para certifi
Rastreo (llamadas recientes más última):
Expediente "
Expediente "
Archivo "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", línea 291, en check_call
elevar CalledProcessError (código de ret, cmd)
subprocess.CalledProcessError: Comando '[' /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 ',' -E ',' -s ',' -m ',' pip ',' instalar ' , '--upgrade', 'certifi'] 'devolvió el estado de salida 1 distinto de cero.
en MacOS /Applications/Python\ 3.6/Install\ Certificates.command
comando funciona para mí
/Applications/Python\ 3.6/Install\ Certificates.command
hizo la magia en MacOSX High Sierra. Gracias
¿Cuál es la solución para quienes utilizan un entorno virtual?
Actualización: parece que ejecutar el mismo comando del sistema señalado anteriormente 👆 también funciona cuando está en un venv activo. ¡Bueno saber!
Si solo desea copiar y pegar en la Terminal:
/Applications/Python\ 3.6/Install\ Certificates.command
¡Gracias!
Esto también podría deberse a que recientemente cambié a una nueva máquina y todavía está parcialmente instalada :)
Para referencia futura: si desea utilizar el instalador dmg de Python, también debe leer el archivo Léame de Python 3 y ejecutar el script
/Applications/Python 3.6/Install Certificates.command
bash para instalar certificados más nuevos.¡Gracias por la rápida respuesta, @aselle!
¡Gracias! ¡Funcionó! :D
Gracias
¿Podría cambiar la URL de descarga de MNIST en contrib / learn / python / learn / datasets / mnist.py para no usar https? Eso ayudará a las personas que tienen este problema. Lo probé en un navegador y el enlace de descarga http funciona.
línea para cambiar:
SOURCE_URL = ' https://storage.googleapis.com/cvdf-datasets/mnist/ '
nueva línea:
SOURCE_URL = ' https://storage.googleapis.com/cvdf-datasets/mnist/ '
Veo que ambas URL son iguales.
¿Podría cambiar la URL de descarga de MNIST en contrib / learn / python / learn / datasets / mnist.py para no usar https? Eso ayudará a las personas que tienen este problema. Lo probé en un navegador y el enlace de descarga http funciona.
línea para cambiar:
SOURCE_URL = ' https://storage.googleapis.com/cvdf-datasets/mnist/ '
nueva línea:
SOURCE_URL = ' https://storage.googleapis.com/cvdf-datasets/mnist/ '
Funcionó para mí.
Solo necesitamos entrada en la Terminal
open "/Applications/Python 3.6/Install Certificates.command"
¿Podría cambiar la URL de descarga de MNIST en contrib / learn / python / learn / datasets / mnist.py para no usar https? Eso ayudará a las personas que tienen este problema. Lo probé en un navegador y el enlace de descarga http funciona.
línea para cambiar:
SOURCE_URL = ' https://storage.googleapis.com/cvdf-datasets/mnist/ '
nueva línea:
SOURCE_URL = ' https://storage.googleapis.com/cvdf-datasets/mnist/ 'Veo que ambas URL son iguales.
cambie ' https: // ... ' a ' http: // ... '
/ Aplicaciones / Python 3.7 / Instalar Certificados.command
Trabaja para mi
¿Cómo hacerlo en Manjaro Linux? Tengo tensorflow de Python3.7.
Si solo desea copiar y pegar en la Terminal:
/Applications/Python\ 3.6/Install\ Certificates.command
¡Gracias hombre! ¡Esto funciona para mi!
Acabo de ejecutar el código en el cuaderno jupyter:
!/Applications/Python\ 3.6/Install\ Certificates.command
vaya a .local / python3.X / lib / python3.6 / site-packages / keras / utils / data_utils.py
`` `solicitudes de importación
request.packages.urllib3.disable_warnings ()
importar ssl
tratar:
_create_unverified_https_context = ssl._create_unverified_context
excepto AttributeError:
# Python heredado que no verifica los certificados HTTPS de forma predeterminada
aprobar
demás:
# Manejar el entorno de destino que no admite la verificación HTTPS
ssl._create_default_https_context = _create_unverified_https_context
''
ahora prueba una nueva instancia de python y ... con suerte funciona: smile_cat:
Esto también podría deberse a que recientemente cambié a una nueva máquina y todavía está parcialmente instalada :)
Para referencia futura: si desea utilizar el instalador dmg de Python, también debe leer el archivo Léame de Python 3 y ejecutar el script
/Applications/Python 3.6/Install Certificates.command
bash para instalar certificados más nuevos.¡Gracias por la rápida respuesta, @aselle!
¡Me salvaste la vida con este comentario! <3
¿Podría cambiar la URL de descarga de MNIST en contrib / learn / python / learn / datasets / mnist.py para no usar https? Eso ayudará a las personas que tienen este problema. Lo probé en un navegador y el enlace de descarga http funciona.
línea para cambiar:
SOURCE_URL = ' https://storage.googleapis.com/cvdf-datasets/mnist/ '
nueva línea:
SOURCE_URL = ' https://storage.googleapis.com/cvdf-datasets/mnist/ '
Esto funciona para mí en ubuntu
cambiando ~/miniconda/envs/py36/lib/python3.6/site-packages/tensorflow_core/python/keras/datasets/mnist.py
Nueva línea
origin_folder = 'http://storage.googleapis.com/tensorflow/tf-keras-datasets/'
Esto es lo que funcionó para mí:
Eso es todo. La utilidad de descarga de keras busca en esa carpeta los datos almacenados en caché antes de pasar a la red.
(Python 3.7.3, tensorflow 2.1.0)
/ Applications / Python 3.6 / Install Certificates.command, ¿esto también funciona para el entorno virtual?
Comentario más útil
Esto también podría deberse a que recientemente cambié a una nueva máquina y todavía está parcialmente instalada :)
Para referencia futura: si desea utilizar el instalador dmg de Python, también debe leer el archivo Léame de Python 3 y ejecutar el script
/Applications/Python 3.6/Install Certificates.command
bash para instalar certificados más nuevos.¡Gracias por la rápida respuesta, @aselle!