pip issue installing almost any library
Asked Answered
L

29

135

I have a difficult time using pip to install almost anything. I'm new to coding, so I thought maybe this is something I've been doing wrong and have opted out to easy_install to get most of what I needed done, which has generally worked. However, now I'm trying to download the nltk library, and neither is getting the job done.

I tried entering

sudo pip install nltk

but got the following response:

/Library/Frameworks/Python.framework/Versions/2.7/bin/pip run on Sat May  4 00:15:38 2013
Downloading/unpacking nltk

  Getting page https://pypi.python.org/simple/nltk/
  Could not fetch URL [need more reputation to post link]: There was a problem confirming the ssl certificate: <urlopen error [Errno 1] _ssl.c:504: error:0D0890A1:asn1 encoding routines:ASN1_verify:unknown message digest algorithm>

  Will skip URL [need more reputation to post link]/simple/nltk/ when looking for download links for nltk

  Getting page [need more reputation to post link]/simple/
  Could not fetch URL https://pypi.python. org/simple/: There was a problem confirming the ssl certificate: <urlopen error [Errno 1] _ssl.c:504: error:0D0890A1:asn1 encoding routines:ASN1_verify:unknown message digest algorithm>

  Will skip URL [need more reputation to post link] when looking for download links for nltk

  Cannot fetch index base URL [need more reputation to post link]

  URLs to search for versions for nltk:
  * [need more reputation to post link]
  Getting page [need more reputation to post link]
  Could not fetch URL [need more reputation to post link]: There was a problem confirming the ssl certificate: <urlopen error [Errno 1] _ssl.c:504: error:0D0890A1:asn1 encoding routines:ASN1_verify:unknown message digest algorithm>

  Will skip URL [need more reputation to post link] when looking for download links for nltk

  Could not find any downloads that satisfy the requirement nltk

No distributions at all found for nltk

Exception information:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/basecommand.py", line 139, in main
    status = self.run(options, args)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/commands/install.py", line 266, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/req.py", line 1026, in prepare_files
    url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/index.py", line 171, in find_requirement
    raise DistributionNotFound('No distributions at all found for %s' % req)
DistributionNotFound: No distributions at all found for nltk

--easy_install installed fragments of the library and the code ran into trouble very quickly upon trying to run it.

Any thoughts on this issue? I'd really appreciate some feedback on how I can either get pip working or something to get around the issue in the meantime.

Latreese answered 4/5, 2013 at 4:29 Comment(1)
For folks, who are getting this error [SSL: TLSV1_ALERT_PROTOCOL_VERSION] for all pip installs, it is because of the recent TLS deprecation by Python.org sites. See this answerKrypton
I
150

I found it sufficient to specify the pypi host as trusted. Example:

pip install --trusted-host pypi.python.org pytest-xdist
pip install --trusted-host pypi.python.org --upgrade pip

This solved the following error:

  Could not fetch URL https://pypi.python.org/simple/pytest-cov/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600) - skipping
  Could not find a version that satisfies the requirement pytest-cov (from versions: )
No matching distribution found for pytest-cov

Update April 2018: To anyone getting the TLSV1_ALERT_PROTOCOL_VERSION error: it has nothing to do with trusted-host/verification issue of the OP or this answer. Rather the TLSV1 error is because your interpreter does not support TLS v1.2, you must upgrade your interpreter. See for example https://news.ycombinator.com/item?id=13539034, http://pyfound.blogspot.ca/2017/01/time-to-upgrade-your-python-tls-v12.html and https://bugs.python.org/issue17128.

Update Feb 2019: For some it may be sufficient to upgrade pip. If the above error prevents you from doing this, use get-pip.py. E.g. on Linux,

curl https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py

More details at https://pip.pypa.io/en/stable/installing/.

Isleen answered 12/8, 2016 at 1:16 Comment(16)
This worked for me, years later, on a windows systemIgnatius
Worked for me using pip3 on a macRags
I was given this message no such option: --trusted-host Scorecard
I still get an error- Could not fetch URL https://pypi.python.org/simple/pytest-xdist/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) - skippingShelbyshelden
it doesn't work for me :/ I tried: sudo -H pip install --trusted-host pypi.python.org numpy or sudo pip install --trusted-host pypi.python.org numpy no luck. Running high sierra on a macbookpro 15". Funny thing, with my previous installation on another mac (same osx it worked, any ideas?Genous
I'm getting the same issue! ` (venv) locust sch699$ sudo -H pip install --no-cache-dir -r requirements.txt --proxy=$http_proxy --trusted-host pypi.python.org Collecting ansible==2.4.2.0 (from -r requirements.txt (line 1)) Could not fetch URL pypi.python.org/simple/ansible: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) - skipping Could not find a version that satisfies the requirement ansible==2.4.2.0 (from -r requirements.txt (line 1)) (from versions: )`Enarthrosis
I finally upgrade to High Sierra and that solved the problem.Shelbyshelden
I have updated my answer to talk about TLSV1 as it is a totally separate issue.Isleen
@Scorecard you probably need to upgrade pipIsleen
@Shelbyshelden What version of MacOS do you have? I updated yesterday to 10.12.6 and I'm still seeing issues.Enarthrosis
@Enarthrosis My current OS version is 10.13.1 (17B1003)Shelbyshelden
@Enarthrosis see this answer: https://mcmap.net/q/49232/-not-able-to-install-python-packages-ssl-tlsv1_alert_protocol_versionKrypton
#49769270Outpoint
The Homebrew instructions linked here didn't work for me: pyfound.blogspot.ca/2017/01/…. The command linked in @truongnm's comment, which uses curl to upgrade pip to version 10.0.1, is what finally worked for me.Jacindajacinta
2018, pip install -r requirements.txt was failing with that error message on Mac OS X Sierra 10.12, TLS 1.0; this worked for me: curl https://bootstrap.pypa.io/get-pip.py | python See https://mcmap.net/q/49232/-not-able-to-install-python-packages-ssl-tlsv1_alert_protocol_versionCyclone
Maybe you could try conda install nltk that might help, if you're not just sticking with pip installation manager.Lepto
N
44

I used pip version 9.0.1 and had the same issue, all the answers above didn't solve the problem, and I couldn't install python / pip with brew for other reasons.

Upgrading pip to 9.0.3 solved the problem. And because I couldn't upgrade pip with pip I downloaded the source and installed it manually.

  1. Download the correct version of pip from - https://pypi.org/simple/pip/
  2. sudo python3 pip-9.0.3.tar.gz - Install pip

Or you can install newer pip with:

curl https://bootstrap.pypa.io/get-pip.py | python
Neglectful answered 12/4, 2018 at 14:12 Comment(4)
as mentioned in my comment on @apatsekin's answer, this is happening due to the recent TLS deprecation for pip. See this answer for details.Krypton
Thanks.. Can confirm the same also worked for Python 2 (am working on something legacy atm)Cluff
If conda/anaconda is why you can't use brew or pip to update pip, then you can use conda install pip to install/upgrade the pip that you are using with your conda environment. You should do this in your root/base conda environment, if you have conda installedKosse
Just installing pip curl https://bootstrap.pypa.io/get-pip.py | pythonKielty
K
33

Pypi removed support for TLS versions less than 1.2

You need to re-install Pip, do

curl https://bootstrap.pypa.io/get-pip.py | python

or for global Python:

curl https://bootstrap.pypa.io/get-pip.py | sudo python
Kristofor answered 22/4, 2018 at 15:10 Comment(2)
This solved the problem on Mac OS version Sierra 10.12.6. Thx!Krakow
Works for me on High Sierra. Thank you.Melanesian
C
32

I used pip3 version 9.0.1 and was unable to install any packages recently via the commandpip3 install.

Mac os version: EI Captain 10.11.5.

python version: 3.5

I tried the command:

curl https://bootstrap.pypa.io/get-pip.py | python

It didn't work for me.

So I uninstalled the older pip and installed the newest version10.0.0 by entering this:

python3 -m pip uninstall pip setuptools
curl https://bootstrap.pypa.io/get-pip.py | python3

Now my problem was solved. If you are using the python2, you can substitute the python3 with python. I hope it also works for you.

By the way, for some rookies like me, you have to enter the code: sudo -i

to gain the root right :) Good luck!

Congruous answered 15/4, 2018 at 9:28 Comment(2)
Echoing the above, was about to try just clean reinstalling python and pip but this worked for me. Thank you!Leander
do not ignore "sudo -i"Insolvable
W
28

You're probably seeing this bug; see also here.

The easiest workaround is to downgrade pip to one that doesn't use SSL: easy_install pip==1.2.1. This loses you the security benefit of using SSL. The real solution is to use a Python distribution linked to a more recent SSL library.

Waugh answered 4/5, 2013 at 4:54 Comment(9)
Thanks Dougal, but pip 1.2.1 doesn't work out either. -Would you mind letting me know how I can update my python distribution to a more recent ssl library?Latreese
actually, i just got everything to work just now. thanks for your help, Dougal!Latreese
@user2348946 What did you do, so that this is useful to people in the future?Waugh
Hi, @Dougal , I am on Kubuntu 13.04 and also having this problem. I use the python that comes with the system, how can i get it linked to a more recent SSL library? Thanks!Guillemette
@Dougal - until someone redistributes python in the repo's for the systems - linux, win and mac - that isn't going to happen. Downloading the pip 1.2.1 tarball from pypi directly and installing this seems to be the best solution - until it works - I suggest ignoring more recent versions of pip.Photolysis
@DannyStaple Yes, that's exactly what I suggested. Of course, using a non-system install of Python isn't very hard; I personally use Anaconda, which is great for numerical applications but would work for anything.Waugh
I realise in some circumstances - installing a non-system python is the preferred way - so you don't interfere with it and are not hampered by system upgrades. This is one thing you couldn't fix just by using a Virtual Env.Photolysis
I tried to use pip 1.2.1 it gave the error when installing cython Could not fetch URL http://pypi.python.org/simple/Cython: HTTP Error 403: SSL is requiredCorves
@Corves Yes; as noted in the comments on the accepted answer, PyPI now requires TLS 1.2. You'll need to update your Python install.Waugh
N
28

Solution - Install any package by marking below hosts trusted

  • pypi.python.org
  • pypi.org
  • files.pythonhosted.org

Temporary solution

pip install --trusted-host pypi.python.org --trusted-host pypi.org --trusted-host files.pythonhosted.org {package name}

Permanent solution - Update your PIP(problem with version 9.0.1) to latest.

pip install --trusted-host pypi.python.org --trusted-host pypi.org --trusted-host files.pythonhosted.org pytest-xdist

python -m pip install --trusted-host pypi.python.org --trusted-host pypi.org --trusted-host files.pythonhosted.org --upgrade pip
Nanettenani answered 4/5, 2018 at 17:33 Comment(4)
Thanks a lot. After 30 tries this works perfektly. I test it with pip versions 20.2.3 and 21.0.1Hibernicism
Worked like a charm with pip version 22.0.4Hydrophane
Thank you, this worked (the permanent solution) > seems like I need to use that entire string now every time... but it is installing packages now.Pyrethrin
Thank you, this worked (the permanent solution) > seems like I need to use that entire string now every time... but it is installing packages now.Pyrethrin
S
22

I tried some of the popular answers, but still could not install any libraries/packages using pip install.

My specific error was 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain using Miniconda for Windows (installer Miniconda3-py37_4.8.3-Windows-x86.exe).

It finally works when I did this: pip install -r requirements.txt --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org

Specifically, I added this to make it work: --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org

Shuttering answered 11/8, 2020 at 17:34 Comment(1)
same - look at this answer above, it worked for me : https://mcmap.net/q/48857/-pip-issue-installing-almost-any-libraryPyrethrin
A
19

Another cause of SSL errors can be a bad system time – certificates won't validate if it's too far off from the present.

Antung answered 24/1, 2014 at 5:7 Comment(1)
Thank you!! That was the only solution which worked for me. My server's clock was WAY off.Drumstick
G
10

The only solution that worked for me is:

sudo curl https://bootstrap.pypa.io/get-pip.py | sudo python

Gotthelf answered 25/5, 2018 at 5:34 Comment(0)
J
9

As posted above by blackjar, the below lines worked for me

pip --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org install xxx

You need to give all three --trusted-host options. I was trying with only the first one after looking at the answers but it didn't work for me like that.

Jane answered 31/7, 2018 at 11:50 Comment(2)
This worked for me. I had the same issue of only trying one trusted issue. Using all three cracks the deal.Appointor
same - yes, his post worked for me as well.Pyrethrin
I
7

I solved a similar problem by adding the --trusted-host pypi.python.org option

Inchworm answered 9/8, 2016 at 20:51 Comment(0)
I
7

To install any other package I have to use the latest version of pip, since the 9.0.1 has this SSL problem. To upgrade the pip by pip itself, I have to solve this SSL problem first. To jump out of this endless loop, I find this only way that works for me.

  1. Find the latest version of pip in this page: https://pypi.org/simple/pip/
  2. Download the .whl file of the latest version.
  3. Use pip to install the latest pip. (Use your own latest version here)

sudo pip install pip-10.0.1-py2.py3-none-any.whl

Now the pip is the latest version and can install anything.

Illogicality answered 22/4, 2018 at 21:12 Comment(0)
L
3

macOS Sierra 10.12.6. Wasn't able to install anything through pip (python installed through homebrew). All the answers above didn't work.

Eventually, upgrade from python 3.5 to 3.6 worked.

brew update
brew doctor #(in case you see such suggestion by brew)

then follow any additional suggestions by brew, i.e. overwrite link to python.

Lialiabilities answered 11/4, 2018 at 22:21 Comment(1)
if you are on Mac OS 10.12, you original issue might be actually related to the recent TLS deprecation of pip. See this post for details. pip has stopped supporting older security protocol on 10.12 and older versions.Krypton
C
3

I had the same problem. I just updated the python from 2.7.0 to 2.7.15. It solves the problem.

You can download here.

Compliancy answered 16/5, 2018 at 8:36 Comment(1)
I just fixed this for the 10th time. Despite understanding the problem on OSX very well and knowing what and where the failure is each "solution" is different form the past. This time the vote goes to 2.7.15 installation on OSX. Simple and effective. Also, there are notes int he release regarding the SSL/OpenSSH issue. Cheers and thanks much!Aldaaldan
F
3

tried

pip --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org install xxx 

and finally worked out, not quite understand why the domain pypi.python.org is changed.

Filly answered 21/6, 2018 at 14:11 Comment(0)
Z
2

You can also use conda to install packages: See http://conda.pydata.org

conda install nltk

The best way to use conda is to download Miniconda, but you can also try

pip install conda
conda init
conda install nltk
Zeta answered 14/6, 2014 at 21:58 Comment(2)
In fairness, if pip install doesn't work, recommending installing another package manager via pip is... well, you know.Reest
This actually worked for me. I installed anaconda after I installed python. I had no idea that anaconda had its own installer until I read this. So, this is the answer that worked for me. Travis' comment addresses the chicken/egg thing because he recommended installing miniconda.Jea
K
2

For me, the latest pip (1.5.6) works fine with the insecure nltk package if you just tell it not to be so picky about security:

pip install --upgrade --force-reinstall --allow-all-external --allow-unverified ntlk nltk
Kosse answered 19/9, 2014 at 18:26 Comment(2)
This is an old answer. Which version of pip are you on?Kosse
I guess the last one. I think I solved the problem by uninstalling everything (Python 2.7, pip etc.) and re-installing everything over and over againGenous
F
1

If you're connecting through a proxy, execute export https_proxy=<your_proxy> (on Unix or Git Bash) and then retry installation.

If you're using Windows cmd, this changes to set https_proxy=<your_proxy>.

Festal answered 23/6, 2017 at 13:22 Comment(0)
R
1

I did the following on Windows 7 to solve this problem.

c:\Program Files\Python36\Scripts> pip install beautifulsoup4 --trusted-host *

The --trusted-host seems to fix the SSL issue and * means every host.

Of course this does not work because you get other errors since there is no version that satisfies the requirement beautifulsoup4, but I don't think that issue is related to the general question.

Rettke answered 4/1, 2018 at 22:27 Comment(0)
A
1

Just uninstall and reinstall pip packages it will workout for you guys.

Mac os version: high Sierra 10.13.6

python version: 3.7

So I uninstalled the older pip and installed the newest version10.0.0 by entering this:

python3 -m pip uninstall pip setuptools

curl https://bootstrap.pypa.io/get-pip.py | python3

Now my problem was solved. If you are using the python2, you can substitute the python3 with python. I hope it also works for you.

Accompany answered 25/9, 2018 at 0:8 Comment(0)
E
1

I solved this issue by update Python3 Virtualenv on my mac. I reference the site https://gist.github.com/pandafulmanda/730a9355e088a9970b18275cb9eadef3
brew install python3
pip3 install virtualenv

Excurvature answered 16/8, 2019 at 7:2 Comment(0)
R
0

If it is only about nltk, I once faced similar problem. Try following guide for installation. Install NLTK

If you are sure it doesn't work with any other module, you may have problem with different versions of Python installed.

Or Give It a Try to see if it says pip is already installed.:

sudo apt-get install python-pip python-dev build-essential 

and see if it works.

Rodge answered 4/5, 2013 at 7:9 Comment(0)
T
0

I solved this issue with the following steps (on sles 11sp2)

zypper remove pip
easy_install pip=1.2.1
pip install --upgrade scons

Here are the same steps in puppet (which should work on all distros)

  package { 'python-pip':
    ensure => absent,
  }
  exec { 'python-pip':
    command  => '/usr/bin/easy_install pip==1.2.1',
    require  => Package['python-pip'],
  }
  package { 'scons': 
    ensure   => latest,
    provider => pip,
    require  => Exec['python-pip'],
  }
Thirtieth answered 31/7, 2014 at 17:2 Comment(0)
H
0

Use Latest version of python on mac Python 2.7.15rc1 https://bugs.python.org/issue17128

Helladic answered 24/4, 2018 at 18:6 Comment(0)
H
0

I had this with PyCharm and upgrading pip to 10.0.1 broke pip with "'main' not found in module" error.

I could solve this problem by installing pip 9.0.3 as seen in some other thread. These are the steps I did:

  1. Downloaded 9.0.3 version of pip from https://pypi.org/simple/pip/ (since pip couldn't be used to install it).
  2. Install pip 9.0.3 from tar.gz python -m pip install pip-9.0.3.tar.gz

Everything started to work after that.

Hilliard answered 25/4, 2018 at 20:33 Comment(0)
U
0

This video tutorial worked for me:

$ curl https://bootstrap.pypa.io/get-pip.py | python
Ultrafilter answered 10/7, 2018 at 21:59 Comment(0)
U
0

Try installing xcode and then using homebrew to install pipenv using "brew install pipenv".

Underage answered 14/6, 2021 at 15:23 Comment(1)
Welcome to Stack Overflow! I recommend against rhetoric questions in answers. They risk being misunderstood as not an answer at all. You are trying to answer the question at the top of this page, aren't you? Otherwise please delete this post.Toland
D
0

For me, I had to unset the variable REQUESTS_CA_BUNDLE which I had to add for the hvac module to work. For more information, check: https://docs.python-requests.org/en/master/user/advanced/#ssl-cert-verification.

Duumvirate answered 25/4, 2022 at 17:52 Comment(0)
D
0

I had same issue installing packages and found the cause in my case... appears I had a third party "media downloader" running on Windows and this was acting as middleman to all SSL traffic so it can intercept and download videos etc... I could see this when I tried the URL that Pycharm failed with:

Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate:

Put https://pypi.org/simple/pip/ in a browser and hover mouse over the SSL area - it will say something like "Verified by YOUR DOWNLOADER PROGRAM" instead of "Verified by Verisign"

Cut out the man in middle attack!

Donela answered 8/9, 2023 at 12:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.