0

I have a Redhat 6 box which originally had python 2.6 installed on it (invoked by /usr/bin/python). A few days ago I installed 2.7.10 (invoked by /usr/local/bin/python or simply python).

Earlier today I installed pip using sudo easy_install pip. The result of whereis pip is pip: /usr/bin/pip2.6 /usr/bin/pip

Then I wanted to install the pandas package by running sudo pip install pandas. It reported success but import pandas produces an error for both versions of python:

myPrompt 733] python
Python 2.7.10 (default, Jul 16 2015, 14:41:11) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named pandas
>>> exit()

myPrompt 734] /usr/bin/python
Python 2.6.6 (r266:84292, Nov 21 2013, 10:50:32) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named pandas
>>> exit()

myPrompt 735] pip install pandas
Traceback (most recent call last):
  File "/usr/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 2655, in <module>
    working_set.require(__requires__)
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 648, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 546, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pip==7.1.0

myPrompt 736] sudo pip install pandas
Enter PASSCODE:
Requirement already satisfied (use --upgrade to upgrade): pandas in /usr/lib64/python2.6/site-packages
Requirement already satisfied (use --upgrade to upgrade): python-dateutil in /usr/lib/python2.6/site-packages (from pandas)
Requirement already satisfied (use --upgrade to upgrade): pytz>=2011k in /usr/lib/python2.6/site-packages (from pandas)
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.7.0 in /usr/lib64/python2.6/site-packages (from pandas)
Requirement already satisfied (use --upgrade to upgrade): six>=1.5 in /usr/lib/python2.6/site-packages (from python-dateutil->pandas)

So there is some sort of confusion with pip configuration and how packages get installed. How can I untangle this? Do I need to reinstall pip?

Ultimately, I don't care about python 2.6 and only want to work with 2.7

Thx

I Z
  • 5,719
  • 19
  • 53
  • 100

3 Answers3

0

Looks like the reason was that I installed the packages as root. Doing

sudo chmod -R ugo+rX /usr/local/lib/python2.7/site-packages

fixed the problem

I Z
  • 5,719
  • 19
  • 53
  • 100
  • I had to do sudo chmod -R ugo+rX /Library/Python/2.7/site-packages/ on my OSX (10.10) and fixed the same issue as well. Thanks. – Guido Aug 13 '15 at 21:07
  • i've been told that this is a security breach because it allows any user to install python modules. – MikeiLL Oct 28 '15 at 04:49
0

For reference, this can happen when you have multiple Python installations, for example via brew. In that case remove one:

brew remove python --force

This one fixed for me.

itarato
  • 795
  • 1
  • 8
  • 24
0

This case can be fixed using the steps provided in the following answer: Easy_install and pip broke: pkg_resources.DistributionNotFound: distribute==0.6.36

It simply replaces the current pip install (which refers to the new/wrong python environment) with a fresh/correct one.

Community
  • 1
  • 1
Vinicius Zani
  • 479
  • 4
  • 5