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) -

  1. channels:
  2. - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ _ _ _ _
  3. - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch _ _
  4. - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ _ _
  5. - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/noarch _ _
  6. - http : / /mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  7. - http://mirrors.aliyun.com/pypi / simple /
  8. - http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/fastai/ _ _ _ _
  9. - http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/ _ _
  10. #- defaults
  11. show_channel_urls: true
  12. #channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda
  13. #default_channels:
  14. # - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  15. # - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  16. # - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  17. # - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
  18. # - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
  19. #custom_channels:
  20. # conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  21. # msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  22. # bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  23. # menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  24. # pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  25. # 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~

Related: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host=‘pypi.org‘,port=443)