0

I am trying to install pandas with pip.

sudo pip install pandas

And I am getting the following error:

➜  ~ which python
/usr/bin/python

➜  ~ python --version
Python 2.7.10

➜  ~ sudo pip install pandas
The directory '/Users/bdisha/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/bdisha/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pandas
  Could not fetch URL https://pypi.python.org/simple/pandas/: 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 pandas (from versions: )
No matching distribution found for pandas

What am I doing wrong?

**

PS: Note that the same happens within a virtual environment

**

David
  • 1,469
  • 5
  • 33
  • 51
  • You may need to update your version of pip ``pip install --upgrade pip`` and then run ``pip install pandas`` – APorter1031 Apr 10 '18 at 20:07
  • Are you sure you want to install packages into Apple's pre-installed Python 2.7 If so, are you sure you don't want to use `virtualenv`? If so, you should clean up your directory permissions (as explained in the error messages) and upgrade `pip` and things should start working. – abarnert Apr 10 '18 at 20:09
  • @abarnert the same error happens in my virtual environment too – David Apr 10 '18 at 20:12
  • The permission issue seems to be a warning (you should fix it anyway) because it the installation didn't stop at that point. For the certificate could it be https://news.ycombinator.com/item?id=13539034? Anyway check your *TLS* version: `python -c "import json, urllib2; print json.load(urllib2.urlopen('https://www.howsmyssl.com/a/check'))['tls_version']"` Then you should probably upgrade your *SSL* lib provider (*OpenSSL*? - if yes try `openssl version -a` - this is just a test, don't know how to upgrade it on *OSX*). – CristiFati Apr 10 '18 at 20:16
  • @APorter1031 I tried upgrading pip and the same error happens: – David Apr 10 '18 at 20:16
  • Your OS X probably has an outdated version of Python whose openssl is too old. `pip` can work around this, but not until you upgrade it, which you can't do because `pip` won't run to upgrade itself, right? I believe you can work around that by running `pip install --upgrade --trusted-host pypi.python.org pip`. If that doesn't work, you can go to the `pip` page on PyPI, download the wheel manually, and upgrade from the local file. – abarnert Apr 10 '18 at 20:16
  • @CristiFati TLS 1.0 – David Apr 10 '18 at 20:17
  • @abarnert I tried your --trusted-host command and I get the same damn error: Could not fetch URL https://pypi.python.org/simple/pip/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) - skipping Requirement already up-to-date: pip in ./.virtualenvs/my_virtual_env/lib/python2.7/site-packages – David Apr 10 '18 at 20:18
  • I think this is a duplicate: https://stackoverflow.com/a/38908406/1240268 – Andy Hayden Apr 10 '18 at 20:20
  • Which versions of `pip` and `setuptools` do you have? (If you don't know how to see, grep them from `pip list`.) – abarnert Apr 10 '18 at 20:21
  • @AndyHayden The answer you linked suggested exactly the same thing I asked the OP to try, which didn't work. – abarnert Apr 10 '18 at 20:21
  • Also, how did you install pip in the first place? (And virtualenv, if it wasn't just `sudo pip install virtualenv`) – abarnert Apr 10 '18 at 20:23
  • @abarnert pip was already installed and I installed virtualenvwrapper with pip ... Suddenly pip does not install anything anymore – David Apr 10 '18 at 20:31
  • @abarnert pip version : pip 9.0.1 AND setuptools version: setuptools 28.8.0 – David Apr 10 '18 at 20:32
  • I think pip 9.0.1 should be new enough for the old-SSL workaround (version 10 is in beta), but maybe setuptools 28 isn't (current version is 39). So, can you try to upgrade `setuptools`? As mentioned, you may have to download the `.whl` file manually off the `PyPI` page and install that. – abarnert Apr 10 '18 at 20:43
  • Possible duplicate of [pip install fails for every package ("Could not find a version that satisfies the requirement")](https://stackoverflow.com/questions/49748063/pip-install-fails-for-every-package-could-not-find-a-version-that-satisfies-th) – Anupam Apr 14 '18 at 05:09

3 Answers3

2

This is due to the recent TLS deprecation for Python.org sites.

This answer has the details.

To summarize, upgrade pip as follows:

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

and then run:

pip install pandas
Anupam
  • 14,950
  • 19
  • 67
  • 94
0

I would try sudo chown -R your_user_name /Users/bdisha/Library/Caches/pip/http and chown -R your_user_name /Users/bdisha/Library/Caches/pip

This post may be useful

Taylor
  • 1,223
  • 1
  • 15
  • 30
0
pip install -U pip

After searching around for quite long, I tried this.

HelloWorld
  • 67
  • 2
  • 15