python unable to get local issuer certificate
时间: 2023-10-28 14:00:00 浏览: 138
Python库 | cert-issuer-2.0.29.tar.gz
This error usually occurs when Python is unable to verify the SSL certificate of the server it is trying to connect to. To resolve this issue, you can try the following steps:
1. Update Certifi: Run the following command to update the Certifi package in Python:
```
pip install --upgrade certifi
```
2. Update OpenSSL: Make sure you have the latest version of OpenSSL installed on your system.
3. Set the SSL_CERT_FILE environment variable: Set the `SSL_CERT_FILE` environment variable to the path of the CA bundle file. You can download the CA bundle file from the official website of the certificate authority or use another trusted source. For example:
```
import os
os.environ['SSL_CERT_FILE'] = '/path/to/ca_bundle.crt'
```
4. Disable certificate verification (not recommended): If you're working in a development environment, you can disable certificate verification as a temporary solution. However, this is not recommended for production environments. To disable verification, you can use the `verify=False` parameter in your requests. For example:
```
import requests
response = requests.get(url, verify=False)
```
Please note that it is important to ensure the security and authenticity of the server you are connecting to. Disabling certificate verification should only be done with caution and for temporary purposes.
阅读全文