AnsweredAssumed Answered

Python script stopped working.  Need help

Question asked by jwb196 on Jul 8, 2020
Latest reply on Jul 8, 2020 by j.herman-esristaff

I have a small Python script that essentially downloads a zip file, unzips it, and saves the contents (shapefiles) to a folder on my network.  It stopped working not too long ago and I'm not sure why.  I was testing each line in the Python Consol, and when it got to the last line shown below (zipresp = urlopen(zipurl)), it gave me a bunch of errors that I don't understand.  Can anyone tell me more on the errors?

 

from urllib.request import urlopen
from zipfile import ZipFile

zipurl = "http://apps.ohiodnr.gov/geodata/Statewide/OGWells_statewide.zip"

# Download the file from the URL
zipresp = urlopen(zipurl)


Traceback (most recent call last):
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\urllib\request.py", line 1318, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\http\client.py", line 1254, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\http\client.py", line 1300, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\http\client.py", line 1249, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\http\client.py", line 1036, in _send_output
self.send(msg)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\http\client.py", line 974, in send
self.connect()
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\http\client.py", line 1415, in connect
server_hostname=server_hostname)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\ssl.py", line 407, in wrap_socket
_context=self, _session=session)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\ssl.py", line 817, in __init__
self.do_handshake()
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\ssl.py", line 1077, in do_handshake
self._sslobj.do_handshake()
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\ssl.py", line 689, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)

 


During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\IPython\core\interactiveshell.py", line 3326, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-2-0dab62d9e32b>", line 7, in <module>
zipresp = urlopen(zipurl)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\urllib\request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\urllib\request.py", line 532, in open
response = meth(req, response)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\urllib\request.py", line 642, in http_response
'http', request, response, code, msg, hdrs)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\urllib\request.py", line 564, in error
result = self._call_chain(*args)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\urllib\request.py", line 504, in _call_chain
result = func(*args)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\urllib\request.py", line 756, in http_error_302
return self.parent.open(new, timeout=req.timeout)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\urllib\request.py", line 526, in open
response = self._open(req, data)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\urllib\request.py", line 544, in _open
'_open', req)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\urllib\request.py", line 504, in _call_chain
result = func(*args)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\urllib\request.py", line 1361, in https_open
context=self._context, check_hostname=self._check_hostname)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\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:852)>

Outcomes