“SSL certificate verify failed” using pip to install packages

后端 未结 14 1847
野性不改
野性不改 2020-12-05 08:01

I am trying to install the Scrapy package (among others) for python using pip. I have tried doing the installation using python 3 and python 2, I have installed/upgraded the

相关标签:
14条回答
  • 2020-12-05 08:21

    One note on the above answers: it is no longer sufficient to add just pypi.python.org to the trusted-hosts in the case where you are behind an HTTPS-intercepting proxy (we have zScaler).

    I currently have the following in my pip.ini:

    trusted-host = pypi.python.org pypi.org files.pythonhosted.org
    

    Running pip -v install pkg will give you some hints as to which hosts might need to be added.

    0 讨论(0)
  • 2020-12-05 08:21

    I had same issue. I was trying to install mysqlclient for my Django project.

    In my case the system date/time wasn't up-to date (Windows 8). That's causing the error. So, updated my system date time and ran the command pip install mysqlclient again. And it did the work.

    Hope this would be helpful for those people who're executing all the commands out there (suggesting in other answers) without checking their system date/time.

    0 讨论(0)
  • 2020-12-05 08:24

    You can try sudo apt-get upgrade to get the latest packages. It fixed the issue on my machine.

    0 讨论(0)
  • 2020-12-05 08:27

    Thank you for the solution. In my case the file %appdata%\pip\pip.ini was not present. I created it manually with this content:

    [global]
    trusted-host = pypi.python.org files.pythonhosted.org pypi.org pypi.io
    
    0 讨论(0)
  • 2020-12-05 08:27

    Pretty unique case here, but having Fiddler running (not even targeting the same process) gave me the same SSL errors. Running pip install with --verbose showed an error with Fiddler, closing Fiddler immediately fixed the issue.

    0 讨论(0)
  • 2020-12-05 08:28

    Something to try --- tell python to not use https with the index directive and a http:// address (not https://)

    pip install --index-url=http://pypi.python.org/simple/ --trusted-host pypi.python.org  Scrapy
    

    You may be behind a corporate firewall and Ive have experiences where even the above failed, though Im not going to pretend like I know enough about firewalls or SSL to understand why. In that case the only way I was able to get around that was to get a certificate file and pass it to python. See kenorb’s answer here for details.

    0 讨论(0)
提交回复
热议问题