Issues with SSL Certification in Tensorflow using Python

I'm having trouble downloading the MNIST data using tensorflow.examples.tutorials.mnist.input_data.read_data_sets(). This function is supposed to send a request to the server to download approximately 1.5GB of data.

However, I keep encountering an error with the SSL certificate that Python is using, as shown in this traceback:

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)

I attempted installing certifications manually by running "Install Certifactions.command" from /Applications/Python 3.6/, but encountered another error related to permissions:

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'

I suspect there may be issues with my filesystem permissions even though I recently reinstalled OSX on this computer. Is there a way to manually install certificates or download the data from a non-https address?

Answer №1

To set up the necessary certificates, you can either double-click on the file located in

/Applications/Python 3.6/Install Certificates.command
if you are using macOS, or execute the following command in a bash terminal:

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

Once this is done, you will have the required certificates installed and be able to download data securely over HTTPS.

For more information, check out the specific thread on TensorFlow GitHub regarding official models.

Answer №2

By changing https to http, I successfully managed to get it up and running.

To fix the issue in contrib/learn/python/learn/datasets/mnist.py, simply adjust the line containing SOURCE_URL=''.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The ZabbixAPI class instance in Python cannot be pickled

I encountered an issue while trying to pickle a ZabbixAPI object of the pyzabbix library using the code snippet below: from pyzabbix import ZabbixAPI from pickle import dumps api = ZabbixAPI('http://platform.autuitive.com/monitoring/') print d ...

Display various options for administrators in Django

I need to allow the admin to select multiple choices at once, using checkboxes. However, when I tried implementing this, it displayed a dropdown list instead of checkboxes. Here is the code snippet: models.py class segmentation_Rules(models.Model): ...

Selenium in Python is failing to click after passing a text file in Xpath for a drop-down menu selection

I have a file with text that I want to use to select options from a dropdown list. However, my current code is not working as expected. f = open('address.txt',encoding="utf-8") lines = f.readlines() for line in lines: y =l ...

Python can be used to inform Google that I accept cookies

Currently, I am encountering a unique issue while attempting to enable cookies and perform a Google search. The problem lies in the fact that the Webdriver is unable to locate the accept cookies button element. Despite my efforts to investigate every possi ...

Executing os.geteuid() on Windows OS in Python

Is there a way to replace the usage of os.geteuid() in Windows since it is only available for Unix? I require this as Celery utilizes the function and for it to work on Windows, I need an alternative for this function. Any assistance would be greatly app ...

python extract data from a JSON file generated by MATLAB

Hey there! Currently, I am in the process of converting Matlab code to Python. One particular issue I am facing revolves around file input and output operations. Specifically, I am attempting to extract data from a JSON file generated using the JSONLab l ...

Organize dates by year-month using the Pandas library

I am working with a python pandas data frame that looks like this Example data frame: +---------+-------+ | Date | value | +---------+-------+ | 2013-12 | A | | 2013-01 | B | | 2013-04 | C | | 2014-06 | D | +---------+-------+ I&apos ...

I am having trouble finding the tabFrame frame shown in the screenshot below

https://i.stack.imgur.com/wCJhN.png I'm having trouble finding the frame labeled tabFrame in the screenshot provided. I did manage to locate outlookFrame successfully. This is the code I used: driver.switch_to.frame('outlookFrame') However ...

Create a new column, Column B, that consists of strings found in Column A using the numpy np.where() function along

Looking to enhance a dataset with unique IDs for multiple individuals, I attempted to utilize np.where(). However, I encountered an issue where only the last entry was being overwritten each time. Here's a sample of my original approach: df = pd.DataF ...

The task scheduler is failing to execute Selenium scripts

Currently, I am utilizing Selenium Webdriver with Python for my automation tasks. Interestingly, everything runs smoothly when executed through IDLE. However, an issue arises when running the script via task scheduler with the "Run only when user is logge ...

What is the process for transferring data processed in Python to Node.js and then forwarding it to Angular?

I am a newcomer to Angular and I'm looking for a way to showcase JSON data from Python in my Angular app using Node.js. I have already utilized child processes to establish the connection between Python and Node.js, but I am facing a challenge on how ...

The floor function in Python works by removing the scientific notation from integer values

Let me illustrate my issue through an example: >>> #When dealing with large numbers, the result may not be as expected >>> k = 20685671025767659927959422028 / 2580360422 >>> k 8.016582043889239e+18 >>> math.floor(k) 801 ...

Utilizing Selenium and Python to Choose an Option from a Dropdown Menu

How can I extract the visible text 'planned works' from this HTML drop-down list? <select id="NewEnquiry.Purpose" data-bind="options: SelectablePurposes, value: Purpose, optionsText: 'Name', optionsCaption: '-- Pl ...

Celery Error: Unable to Receive Emails via Celery

New to Python Django and Celery, I'm looking to set up Celery locally. Right now, my focus is on configuring error emails for failed tasks. Here's what I've done so far: Added the following code to setting.py CELERY_SEND_TASK_ERROR_EMAILS ...

The Keras Conv1d Input Shape Validation Issue: Alert triggered during input validation

Using keras with TF backend, I am in the process of constructing a simple Conv1d network. The dataset has the dimensions as follows: train feature shape: (33960, 3053, 1) train label shape: (33960, 686, 1) The model is defined as: def create_conv_model( ...

Transforming a cURL request into Python code

I'm in the process of translating this cURL request to Python code. My ultimate goal is to store the output in a CSV file, but I first need to establish a connection. curl --compressed -H 'Accept: application/json' -H 'X-Api-Key: 123abc ...

Leveraging various data sets in Gridspec

My goal is to create a subplot inside another subplot, and after finding some code that uses the gridspec method for this purpose, I have successfully modified it to display the figures as desired. However, I am struggling with getting a different dataset ...

Switching the value of a dropdown selection in Python using Selenium

Upon analyzing a webpage, I came across the following HTML elements: <select name="limit"> <option value="20">20</option> <option value="50">50</option> <option value="100" ...

Getting the attribute of a react component through a class by utilizing selenium webdriver

I am working with HTML code in Python using Selenium WebDriver. Specifically, I need to extract the text Unblock from a specific element on the 4th line. Can anyone provide guidance on how to achieve this? <a class="btn btn-micro hasTooltip" hre ...

Can someone please provide the PyCharm "Documentation URL" links for the libraries listed below?

I really appreciate the "quick documentation" feature in PyCharm and other JetBrains IDEs, but it requires the specific "Documentation URL" for each library to be set under Preferences > Tools > Python External Documentation. I'm curious if any ...