Python无法访问网络,出现SSL: CERTIFICATE_VERIFY_FAILED错误

Python无法访问网络,出现SSL: CERTIFICATE_VERIFY_FAILED错误

新安装的系统。也许是ssl库文件或者某些原因,主要是无法验证https证书。

方案参考:https://stackoverflow.com/questions/77442172/ssl-certificate-verify-failed-certificate-verify-failed-unable-to-get-local-is

具体步骤:

pip install pip-system-certs
pip install certifi

如果系统是 Linux:

export SSL_CERT_FILE=$(python3 -m certifi)
python main.py # replace with your module name

如果是 Windows:

python3 -m certifi
# 将刚才显示的模块路径填写
set  SSL_CERT_FILE=xxxxxxxxxxxxxxxx
python main.py # replace with your module name

Copyright: 采用 知识共享署名4.0 国际许可协议进行许可

Links: https://zwc365.com/2025/04/11/python-wu-fa-fang-wen-wang-luo

Buy me a cup of coffee ☕.