After moving from python 3.7 to python 3.8 I started receiving this errors when I'm doing pd.read_csv('https_link_here.csv')
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/Applications/Dev Tools/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_umd.py", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "/Applications/Dev Tools/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Users/dmitry/projects/work/python_scripts/covid_cases_deaths_dashboard/covid_dashboard_v.2.2.py", line 202, in <module>
inp_who = pd.read_csv('https://covid19.who.int/WHO-COVID-19-global-data.csv')
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/io/parsers.py", line 686, in read_csv
return _read(filepath_or_buffer, kwds)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/io/parsers.py", line 434, in _read
fp_or_buf, _, compression, should_close = get_filepath_or_buffer(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/io/common.py", line 183, in get_filepath_or_buffer
req = urlopen(filepath_or_buffer)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/io/common.py", line 137, in urlopen
return urllib.request.urlopen(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 525, in open
response = self._open(req, data)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 542, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 502, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 1393, in https_open
return self.do_open(http.client.HTTPSConnection, req,
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 1353, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)>
When I'm changing interpreter back to python 3.7 everything going well.
How it could be fixed?
If you are facing the same issue please go to python 3.8 folder and run Install Certificates.command
Related
This question already has answers here:
SSL: CERTIFICATE_VERIFY_FAILED error when loading data into seaborn?
(3 answers)
Closed 9 months ago.
#i am getting url error how do i resolve it
C:\Python\python.exe E:/data_science/Python_basic/module1_eda/EDA.py
Traceback (most recent call last):
File "C:\Python\lib\urllib\request.py", line 1350, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "C:\Python\lib\http\client.py", line 1277, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Python\lib\http\client.py", line 1323, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Python\lib\http\client.py", line 1272, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Python\lib\http\client.py", line 1032, in _send_output
self.send(msg)
File "C:\Python\lib\http\client.py", line 972, in send
self.connect()
File "C:\Python\lib\http\client.py", line 1447, in connect
server_hostname=server_hostname)
File "C:\Python\lib\ssl.py", line 423, in wrap_socket
session=session
File "C:\Python\lib\ssl.py", line 870, in _create
self.do_handshake()
File "C:\Python\lib\ssl.py", line 1139, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1091)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:/data_science/Python_basic/module1_eda/EDA.py", line 9, in <module>
adult = pd.read_csv(data_url,names=column_headers)
File "C:\Python\lib\site-packages\pandas\util\_decorators.py", line 311, in wrapper
return func(*args, **kwargs)
File "C:\Python\lib\site-packages\pandas\io\parsers\readers.py", line 586, in read_csv
return _read(filepath_or_buffer, kwds)
File "C:\Python\lib\site-packages\pandas\io\parsers\readers.py", line 482, in _read
parser = TextFileReader(filepath_or_buffer, **kwds)
File "C:\Python\lib\site-packages\pandas\io\parsers\readers.py", line 811, in __init__
self._engine = self._make_engine(self.engine)
File "C:\Python\lib\site-packages\pandas\io\parsers\readers.py", line 1040, in _make_engine
return mapping[engine](self.f, **self.options) # type: ignore[call-arg]
File "C:\Python\lib\site-packages\pandas\io\parsers\c_parser_wrapper.py", line 51, in __init__
self._open_handles(src, kwds)
File "C:\Python\lib\site-packages\pandas\io\parsers\base_parser.py", line 229, in _open_handles
errors=kwds.get("encoding_errors", "strict"),
File "C:\Python\lib\site-packages\pandas\io\common.py", line 614, in get_handle
storage_options=storage_options,
File "C:\Python\lib\site-packages\pandas\io\common.py", line 312, in _get_filepath_or_buffer
with urlopen(req_info) as req:
File "C:\Python\lib\site-packages\pandas\io\common.py", line 212, in urlopen
return urllib.request.urlopen(*args, **kwargs)
File "C:\Python\lib\urllib\request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "C:\Python\lib\urllib\request.py", line 525, in open
response = self._open(req, data)
File "C:\Python\lib\urllib\request.py", line 543, in _open
'_open', req)
File "C:\Python\lib\urllib\request.py", line 503, in _call_chain
result = func(*args)
File "C:\Python\lib\urllib\request.py", line 1393, in https_open
context=self._context, check_hostname=self._check_hostname)
File "C:\Python\lib\urllib\request.py", line 1352, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1091)>
Process finished with exit code 1
Seems like you're trying to download the datafile from some URL and because of self-signed certificate you're getting this error. You can simply disable SSL verification during fetching.
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
I'm trying to upload example from dash documentation.
When I try (with PyCharm)
df = pd.read_csv(
'https://raw.githubusercontent.com/plotly/datasets/master/solar.csv'
)
I get these errors.
But when I try the same code with Anaconda Jupyter it works fine. It means problem is not in my OS but in PyCharm.
Can you advise what should I do?
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 1342, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1010, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 950, in send
self.connect()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1424, in connect
self.sock = self._context.wrap_socket(self.sock,
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ssl.py", line 1040, in _create
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/zaurguliyev/Documents/PyTraining/PyCharm/test/sales_analysis/main.py", line 4, in <module>
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/solar.csv')
File "/Users/zaurguliyev/Documents/PyTraining/PyCharm/test/sales_analysis/venv/lib/python3.9/site-packages/pandas/util/_decorators.py", line 311, in wrapper
return func(*args, **kwargs)
File "/Users/zaurguliyev/Documents/PyTraining/PyCharm/test/sales_analysis/venv/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 680, in read_csv
return _read(filepath_or_buffer, kwds)
File "/Users/zaurguliyev/Documents/PyTraining/PyCharm/test/sales_analysis/venv/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 575, in _read
parser = TextFileReader(filepath_or_buffer, **kwds)
File "/Users/zaurguliyev/Documents/PyTraining/PyCharm/test/sales_analysis/venv/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 933, in __init__
self._engine = self._make_engine(f, self.engine)
File "/Users/zaurguliyev/Documents/PyTraining/PyCharm/test/sales_analysis/venv/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 1217, in _make_engine
self.handles = get_handle( # type: ignore[call-overload]
File "/Users/zaurguliyev/Documents/PyTraining/PyCharm/test/sales_analysis/venv/lib/python3.9/site-packages/pandas/io/common.py", line 670, in get_handle
ioargs = _get_filepath_or_buffer(
File "/Users/zaurguliyev/Documents/PyTraining/PyCharm/test/sales_analysis/venv/lib/python3.9/site-packages/pandas/io/common.py", line 339, in _get_filepath_or_buffer
with urlopen(req_info) as req:
File "/Users/zaurguliyev/Documents/PyTraining/PyCharm/test/sales_analysis/venv/lib/python3.9/site-packages/pandas/io/common.py", line 239, in urlopen
return urllib.request.urlopen(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 214, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 517, in open
response = self._open(req, data)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 534, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 494, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 1385, in https_open
return self.do_open(http.client.HTTPSConnection, req,
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 1345, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)>
Process finished with exit code 1
I think you should check whether you're using the same Python interpreter and Pandas version in both Jupyter and PyCharm.
Find Jupyter interpreter: How to know which Python is running in Jupyter notebook?
(Check this if using Spyder: https://docs.spyder-ide.org/current/faq.html#using-existing-environment)
Check if it's the same in PyCharm: https://www.jetbrains.com/help/pycharm/configuring-python-interpreter.html#interpreter
Before I begin here is my code in Python, for which I am trying to download an image from the web (I am just getting use to Python, not for any specific reason).
import random
import urllib.request
def download_web_image(url):
name = random.randrange(1, 1000)
full_name = str(name) + '.jpg'
urllib.request.urlretrieve(url, full_name)
download_web_image('https://www.thenewboston.com/photos/users/2/resized/a403d4e7fb26d7373009c97d68b2448b.jpg')
However when I run the code this error appears:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 1240, in do_open
h.request(req.get_method(), req.selector, req.data, headers)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 1083, in request
self._send_request(method, url, body, headers)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 1128, in _send_request
self.endheaders(body)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 1079, in endheaders
self._send_output(message_body)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 911, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 854, in send
self.connect()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 1237, in connect
server_hostname=server_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py", line 376, in wrap_socket
_context=self)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py", line 747, in __init__
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py", line 983, in do_handshake
self._sslobj.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py", line 628, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:646)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/jake/PycharmProjects/BuckyTutorials/download image.py", line 9, in <module>
download_web_image('https://www.thenewboston.com/photos/users/2/resized/a403d4e7fb26d7373009c97d68b2448b.jpg')
File "/Users/jake/PycharmProjects/BuckyTutorials/download image.py", line 7, in download_web_image
urllib.request.urlretrieve(url, full_name)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 187, in urlretrieve
with contextlib.closing(urlopen(url, data)) as fp:
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 162, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 465, in open
response = self._open(req, data)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 483, in _open
'_open', req)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 443, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 1283, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 1242, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:646)>
This happens in both IDLE and pycharm. What am I doing wrong?
I am trying Google's Native Client SDK.
OS is Windows 7, I've already installed python 2.7.9 and setup the environment variable path accordingly.
I also downloaded nacl_sdk.zip from https://developer.chrome.com/native-client/sdk/download and extracted it.
However, as I run the command "naclsdk list" as it is described on the download page, I got the following messages:
C:\Temp\nacl_sdk>naclsdk list
Traceback (most recent call last):
File "C:\Temp\nacl_sdk\sdk_tools\sdk_update_main.py", line 759, in
sys.exit(main(sys.argv[1:]))
File "C:\Temp\nacl_sdk\sdk_tools\sdk_update_main.py", line 752, in main
InvokeCommand(args)
File "C:\Temp\nacl_sdk\sdk_tools\sdk_update_main.py", line 741, in InvokeCommand
command(options, args[1:], config)
File "C:\Temp\nacl_sdk\sdk_tools\sdk_update_main.py", line 510, in Update
manifest = LoadManifestFromURLs([options.manifest_url] + config.GetSources())
File "C:\Temp\nacl_sdk\sdk_tools\sdk_update_main.py", line 238, in LoadManifestFromURLs
url_stream = UrlOpen(url)
File "C:\Temp\nacl_sdk\sdk_tools\sdk_update_main.py", line 114, in UrlOpen
return url_opener.open(request)
File "C:\python27\lib\urllib2.py", line 431, in open
response = self._open(req, data)
File "C:\python27\lib\urllib2.py", line 449, in _open
'_open', req)
File "C:\python27\lib\urllib2.py", line 409, in _call_chain
result = func(*args)
File "C:\python27\lib\urllib2.py", line 1240, in https_open
context=self._context)
TypeError: do_open() got an unexpected keyword argument 'context'
Traceback (most recent call last):
File "C:\Temp\nacl_sdk\sdk_tools\sdk_update_main.py", line 759, in
sys.exit(main(sys.argv[1:]))
File "C:\Temp\nacl_sdk\sdk_tools\sdk_update_main.py", line 752, in main
InvokeCommand(args)
File "C:\Temp\nacl_sdk\sdk_tools\sdk_update_main.py", line 741, in InvokeCommand
command(options, args[1:], config)
File "C:\Temp\nacl_sdk\sdk_tools\sdk_update_main.py", line 444, in List
manifest = LoadManifestFromURLs([options.manifest_url] + config.GetSources())
File "C:\Temp\nacl_sdk\sdk_tools\sdk_update_main.py", line 238, in LoadManifestFromURLs
url_stream = UrlOpen(url)
File "C:\Temp\nacl_sdk\sdk_tools\sdk_update_main.py", line 114, in UrlOpen
return url_opener.open(request)
File "C:\python27\lib\urllib2.py", line 431, in open
response = self._open(req, data)
File "C:\python27\lib\urllib2.py", line 449, in _open
'_open', req)
File "C:\python27\lib\urllib2.py", line 409, in _call_chain
result = func(*args)
File "C:\python27\lib\urllib2.py", line 1240, in https_open
context=self._context)
TypeError: do_open() got an unexpected keyword argument 'context'
In fact, no matter what command I use, it doesn't seem to work at all.
Does anyone know the solution?
having the same issue.
Found this link: http://forums.udacity.com/questions/100247273/urllib2-may-be-a-bug-to-find-the-appropriate-method-overload
Solved by editing python27/lib/urllib2.py...
Hope it helps!
I have a problem while deploying application to GAE. I use ubuntu. When I type command to update application this error occurs:
2011-07-22 20:13:28,598 ERROR appcfg.py:2064 An unexpected error occurred. Aborting.
Traceback (most recent call last):
File "/home/grzegorz/google_appengine/google/appengine/tools/appcfg.py", line 2005, in DoUpload
missing_files = self.Begin()
File "/home/grzegorz/google_appengine/google/appengine/tools/appcfg.py", line 1674, in Begin
self.Send('/api/appversion/create', payload=self.config.ToYAML())
File "/home/grzegorz/google_appengine/google/appengine/tools/appcfg.py", line 1632, in Send
return self.rpcserver.Send(url, payload=payload, **self.params)
File "/home/grzegorz/google_appengine/google/appengine/tools/appengine_rpc.py", line 365, in Send
f = self.opener.open(req)
File "/usr/lib/python2.7/urllib2.py", line 391, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 409, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 369, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 1193, in https_open
return self.do_open(httplib.HTTPSConnection, req)
File "/home/grzegorz/google_appengine/lib/fancy_urllib/fancy_urllib/__init__.py", line 367, in do_open
raise url_error
URLError: <urlopen error [Errno 110] Connection timed out>
Traceback (most recent call last):
File "./google_appengine/appcfg.py", line 76, in <module>
run_file(__file__, globals())
File "./google_appengine/appcfg.py", line 72, in run_file
execfile(script_path, globals_)
File "/home/grzegorz/google_appengine/google/appengine/tools/appcfg.py", line 3708, in <module>
main(sys.argv)
File "/home/grzegorz/google_appengine/google/appengine/tools/appcfg.py", line 3699, in main
result = AppCfgApp(argv).Run()
File "/home/grzegorz/google_appengine/google/appengine/tools/appcfg.py", line 2345, in Run
self.action(self)
File "/home/grzegorz/google_appengine/google/appengine/tools/appcfg.py", line 3484, in __call__
return method()
File "/home/grzegorz/google_appengine/google/appengine/tools/appcfg.py", line 2745, in Update
app_summary = self.UpdateVersion(rpcserver, self.basepath, appyaml)
File "/home/grzegorz/google_appengine/google/appengine/tools/appcfg.py", line 2734, in UpdateVersion
lambda path: self.opener(os.path.join(basepath, path), 'rb'))
File "/home/grzegorz/google_appengine/google/appengine/tools/appcfg.py", line 2005, in DoUpload
missing_files = self.Begin()
File "/home/grzegorz/google_appengine/google/appengine/tools/appcfg.py", line 1674, in Begin
self.Send('/api/appversion/create', payload=self.config.ToYAML())
File "/home/grzegorz/google_appengine/google/appengine/tools/appcfg.py", line 1632, in Send
return self.rpcserver.Send(url, payload=payload, **self.params)
File "/home/grzegorz/google_appengine/google/appengine/tools/appengine_rpc.py", line 365, in Send
f = self.opener.open(req)
File "/usr/lib/python2.7/urllib2.py", line 391, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 409, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 369, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 1193, in https_open
return self.do_open(httplib.HTTPSConnection, req)
File "/home/grzegorz/google_appengine/lib/fancy_urllib/fancy_urllib/__init__.py", line 367, in do_open
raise url_error
urllib2.URLError: <urlopen error [Errno 110] Connection timed out>
I tried to figure out why this happens, especially that it didn't happen to me before.
Anything that I've done about it just didn't work. What's weird is that if I keep trying, then after about 20-30 attemps - it just magically deploys..
In my opinion there might be some Wifi problems. For example when I start xChat - it can't connect to server. I think that this problems might be connected.
Nevertheless I can't figure out anything, so I would be thankful for any help.