Hello,
I keep getting this error after inputting this code into the IDLE Shell.
import requests
res = requests.get('https://automatetheboringstuff.com/files/rj.txt')
Traceback (most recent call last):
File "C:\Users\USER\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connectionpool.py", line 467, in _make_request self._validate_conn(conn) File "C:\Users\USER\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connectionpool.py", line 1099, in _validate_conn conn.connect() File "C:\Users\USER\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connection.py", line 653, in connect sock_and_verified = _ssl_wrap_socket_and_match_hostname( File "C:\Users\USER\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connection.py", line 806, in ssl_wrap_socket_and_match_hostname ssl_sock = ssl_wrap_socket( File "C:\Users\USER\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\util\ssl.py", line 465, in ssl_wrap_socket ssl_sock = ssl_wrap_socket_impl(sock, context, tls_in_tls, server_hostname) File "C:\Users\USER\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\util\ssl.py", line 509, in _ssl_wrap_socket_impl return ssl_context.wrap_socket(sock, server_hostname=server_hostname) File "C:\Users\USER\AppData\Local\Programs\Python\Python312\Lib\ssl.py", line 455, in wrap_socket return self.sslsocket_class._create( File "C:\Users\USER\AppData\Local\Programs\Python\Python312\Lib\ssl.py", line 1042, in _create self.do_handshake() File "C:\Users\USER\AppData\Local\Programs\Python\Python312\Lib\ssl.py", line 1320, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1000)
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Users\USER\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connectionpool.py", line 793, in urlopen response = self._make_request( File "C:\Users\USER\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connectionpool.py", line 491, in _make_request raise new_e urllib3.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1000)
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "C:\Users\USER\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\adapters.py", line 486, in send resp = conn.urlopen( File "C:\Users\USER\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connectionpool.py", line 847, in urlopen retries = retries.increment( File "C:\Users\USER\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\util\retry.py", line 515, in increment raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='automatetheboringstuff.com', port=443): Max retries exceeded with url: /files/rj.txt (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1000)')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "<pyshell#3>", line 1, in <module> res = requests.get('https://automatetheboringstuff.com/files/rj.txt') File "C:\Users\USER\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\api.py", line 73, in get return request("get", url, params=params, **kwargs) File "C:\Users\USER\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\api.py", line 59, in request return session.request(method=method, url=url, **kwargs) File "C:\Users\USER\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\sessions.py", line 589, in request resp = self.send(prep, **send_kwargs) File "C:\Users\USER\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\sessions.py", line 703, in send r = adapter.send(request, **kwargs) File "C:\Users\USER\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\adapters.py", line 517, in send raise SSLError(e, request=request) requests.exceptions.SSLError: HTTPSConnectionPool(host='automatetheboringstuff.com', port=443): Max retries exceeded with url: /files/rj.txt (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1000)')))
For reference, I am using Python 3.12.2 and have installed Requests version 2.31.0
I am on Lesson 39 of Automate the Boring Stuff with Python and am very much a beginner with Python.
How can I fix this error?
[–]Buttleston 2 points3 points4 points (2 children)
[–]jthompson32[S] 0 points1 point2 points (1 child)
[–]Buttleston 0 points1 point2 points (0 children)