There was a problem confirming the ssl certificate: HTTPSConnectionPool(host=‘pypi.org‘,port=443)
After configuring the anaconda environment (if the conda command cannot install the library or the installation is slow, see the end of the article), I want to use pip install to install the corresponding package (my example installs the yacs library), and found the following error:
Could not fetch URL https://pypi.org/simple/yacs/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/yacs/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)'))) - skipping
It is similar that your computer prompts a security problem when you open the pypi.org website, and reports a certificate-related error.
The solution is to designate the website as trusted.
pip install --trusted-host pypi .org installed package name.whl
If the following problem occurs after this:
ERROR: Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Max retries exceeded with url: /packages/64/c2/b80047c7ac2478f9501676c988a5411ed5572f35d1beff9cae07d321512c/PyYAML-5.3.1.tar.gz (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)')))
Then set files.pythonhosted.org to trusted and it will be OK.
pip install --trusted-host pypi .org --trusted-host files .pythonhosted .org installed package name.whl
At this point, I will no longer report this certificate issue here~
When I used the conda command to install the library or create an environment before, I encountered a situation where it could not be installed (due to source problems), and here is the source configuration problem:
There are many articles for reference, such as: anaconda conda switch to domestic source and Anaconda 3 to replace domestic Tsinghua source tutorial (can't understand you hit me)
The content of condarc I configured under ubuntu is as follows (where # indicates that the line is commented out, and the addresses in many sources on the Internet are https. I tried http here and succeeded, which is a reference. For specific questions, please refer to the above two article link) -
- channels:
- - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ _ _ _ _
- - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch _ _
- - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ _ _
- - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/noarch _ _
- - http : / /mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
- - http://mirrors.aliyun.com/pypi / simple /
- - http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/fastai/ _ _ _ _
- - http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/ _ _
- #- defaults
- show_channel_urls: true
- #channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda
- #default_channels:
- # - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- # - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
- # - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- # - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
- # - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
- #custom_channels:
- # conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
- # msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
- # bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
- # menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
- # pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
- # simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
Among them, defaults is recommended to be commented out. The default is the source download of anaconda, which is relatively slow~