Pycharm中运行脚本提示:SSL Error
程序员文章站
2022-05-10 09:32:56
...
问题:
今天用Pycharm跑脚本,提示SSL Error:
Traceback (most recent call last):
File "C:\Users\\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 594, in urlopen
self._prepare_proxy(conn)
File "C:\Users\\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 805, in _prepare_proxy
conn.connect()
File "C:\Users\\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connection.py", line 344, in connect
ssl_context=context)
File "C:\Users\\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\ssl_.py", line 344, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 412, in wrap_socket
session=session
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 850, in _create
self.do_handshake()
File "C:\Users\\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 1108, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1045)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\adapters.py", line 449, in send
timeout=timeout
File "C:\Users\\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "C:\Users\\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\retry.py", line 398, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='www.baidu.com', 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:1045)')))
解决思路:
1.先用postman跑通了脚本,生成的代码在Pycharm里面还是不行
2.于是在代码里面加入:verify=False,可以跑通
requests.get('https://github.com', verify=False)
3.采用2的方法可以成功,但是每一条case都要改动,工作量有点大。突然想起来,我的Fiddler是打开状态的,因此猜测是否因为Fiddler的原因。于是关闭Fiddler,果然就跑成功了。
跑脚本的时候,一定要注意环境,关闭Fiddler,Charles等类似工具
上一篇: Linux是如何启动的?
下一篇: php执行脚本获得root权限问题
推荐阅读
-
pycharm运行脚本时控制台不输出print中的日志
-
VSCode中autopep8无法运行问题解决方案(提示Error: Command failed,usage)
-
CentOS7运行.sh脚本提示syntax error: unexpected end of file的解决方法
-
pycharm运行脚本时控制台不输出print中的日志
-
Pycharm中运行脚本提示:SSL Error
-
VSCode中autopep8无法运行问题解决方案(提示Error: Command failed,usage)
-
CentOS7运行.sh脚本提示syntax error: unexpected end of file的解决方法