Closed AllanLeanderRostockHansen closed 2 years ago
It looks like some of your root certificates are too old. Can you try to updating conda install ca-certificates
.
Or install the certificates manually: https://medium.com/@codedigger/api-call-over-internet-fails-with-certificate-expired-error-from-09-30-2021-windows-838d3a793e9f
The source code can be found here: https://github.com/pola-rs/polars-book/tree/master/user_guide/src/examples/groupby_dsl, which defines dataset
here: https://github.com/pola-rs/polars-book/blob/master/user_guide/src/examples/groupby_dsl/dataset.py. So the data being pulled is this url: https://theunitedstates.io/congress-legislators/legislators-historical.csv
.
I get a similar error with:
df = pl.read_csv( "https://gist.githubusercontent.com/ritchie46/cac6b337ea52281aa23c049250a4ff03/raw/89a957ff3919d90e6ef2d34235e6bf22304f3366/pokemon.csv")
And this message:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 1348, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1282, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1328, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1277, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1037, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 975, in send
self.connect()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1454, in connect
self.sock = self._context.wrap_socket(self.sock,
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 512, in wrap_socket
return self.sslsocket_class._create(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 1070, in _create
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 1341, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3369, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-101-c42ee15dec88>", line 1, in <cell line: 1>
df = pl.read_csv(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/polars/io.py", line 397, in read_csv
with _prepare_file_arg(file, **storage_options) as data:
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/polars/io.py", line 120, in _prepare_file_arg
return _process_http_file(file)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/polars/io.py", line 60, in _process_http_file
with urlopen(path) as f:
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 216, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 519, in open
response = self._open(req, data)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 536, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 496, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 1391, in https_open
return self.do_open(http.client.HTTPSConnection, req,
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 1351, 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:997)>
No, that is obviously for windows, besides this MacBook is only a week old.
Please note that although the solution (https://github.com/pola-rs/polars/issues/2854#issuecomment-1061749335) has Windows-specific instruction, it is the same ssl certficate issue, as the last line of your stack trace says:
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)>
There may have been an issue with the ssl certificate of the website at the time. I cannot verify this, as the current certificate (from Let's Encrypt) is valid from Sun, 10 Apr 2022 02:01:10 GMT onwards, and is currently valid on my W10 machine.
Given that no update has been posted for a month, I am going to assume all has been resolved. Feel free to open a new issue if you run into any issues that cannot be resolved by updating the certificates.
I got this issue recently on a macbook and resolved it with
/Applications/Python\ 3.11/Install\ Certificates.command
where you might need to tab complete to get your python version
What data is used for the Python tutorial?
The congress dataset is imported from a dataset package (this section in the tutorial). While the data seems to be available in this repo, I'm not sure which of the available datasets to use.
Possible bug when reading a CSV from a web-address
In the issues for this repo, I've found a reference to the dataset in the URL below, but reading it from the web-address using
pl.read_csv
results in a SSL error. Usingrequests.get
to fetch the data works without hiccups:This works
This fails
Notice that I'm using an Anaconda Python (3.9.10) distribution on Windows 10, which is known to have some SSL issues.
And this is the error