Python을 사용하여 requests.get
모든 사이트에서 정보를 얻을 때 오류가 발생합니다.
Traceback (most recent call last): File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 603, in urlopen
chunked=chunked) File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 344, in _make_request
self._validate_conn(conn) File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 843, in _validate_conn
conn.connect() File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connection.py", line 370, in connect
ssl_context=context) File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\ssl_.py", line 355, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname) File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 423, in wrap_socket
session=session File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 870, in _create
self.do_handshake() File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 1139, in do_handshake
self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\adapters.py", line 449, in send
timeout=timeout File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 641, in urlopen
_stacktrace=sys.exc_info()[2]) File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\retry.py", line 399, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='e.mail.ru', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Users\ADMIN\Desktop\test1.py", line 3, in <module>
r=requests.get("https://e.mail.ru") File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\api.py", line 75, in get
return request('get', url, params=params, **kwargs) File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\api.py", line 60, in request
return session.request(method=method, url=url, **kwargs) File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs) File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\sessions.py", line 646, in send
r = adapter.send(request, **kwargs) File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\adapters.py", line 514, in send
raise SSLError(e, request=request) requests.exceptions.SSLError: HTTPSConnectionPool(host='e.mail.ru', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)')))
또한 을 사용할 때도 pip install
동일한 오류가 발생합니다.
C:\WINDOWS\system32>cd C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\scripts
C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\Scripts>pip install ssl
Collecting ssl
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)'))': /simple/ssl/
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)'))': /simple/ssl/
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)'))': /simple/ssl/
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)'))': /simple/ssl/
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)'))': /simple/ssl/
Could not fetch URL https://pypi.org/simple/ssl/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/ssl/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)'))) - skipping
Could not find a version that satisfies the requirement ssl (from versions: )
No matching distribution found for ssl
You are using pip version 19.0.3, however version 19.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
신뢰할 수 있는 사이트 URL을 만들려고 했습니다.
pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org pip setuptools
하지만 난 아무것도 없어요.
저는 Windows 8, Python 3.7.4 및 pip 19.0.3을 사용합니다.
다음을 사용하여 SSL 확인을 무시할 수 있다는 것을 알고 있습니다.
r = requests.get(url = URL, verify=False)
하지만 지금은 여전히 사용할 수 없으며 pip install
이러한 오류를 지속적으로 무시할 필요는 없습니다.
답변1
코드를 다음과 같이 변경하면 작동합니다.
from urllib3.exceptions import InsecureRequestWarning
.
.
.
requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)
r = requests.get(url=URL, verify=False)
답변2
request.request('GET'...
대신 사용하십시오 request.get(...
.
시스템 시간이 올바른지 확인할 수도 있습니다.
date
잘못 구성된 경우 다음을 수행하여 시간대 및 날짜 자동 동기화를 설정하세요.
sudo apt-get install ntp ntpdate && service ntp stop
dpkg-reconfigure tzdata
ntpdate-debian
service ntp start
그것은 나에게 효과적입니다.