7

This is on CentOs 6.6. I am trying to set up a scientific python environment. I want to avoid Anaconda. When trying to install matplotlib, I get "ImportError: No module named pkg_resources". Full install history:

sudo yum install gcc-c++.x86_64
sudo yum install gcc
sudo yum install atlas atlas-devel lapack-devel blas-devel
sudo yum install python-devel
sudo pip install numpy
sudo pip install scipy
sudo pip install pandas
sudo pip install matplotlib

At the last step, I get the message

Complete output from command python setup.py egg_info:
The required version of distribute (>=0.6.28) is not available,
and can't be installed while this script is running. Please
install a more recent version first, using
'easy_install -U distribute'.

Then I do

sudo pip install --upgrade distribute

which installs distribute-0.7.3, setuptools-18.0.1. Then:

sudo pip install matplotlib

which results in:

File "/usr/bin/pip", line 5, in <module>
  from pkg_resources import load_entry_point
ImportError: No module named pkg_resources

Any ideas?

Update

After the above steps, setuptools and pip are broken in this installation. From a python shell, doing help() followed by modules does not list setuptools. A search in the filesystem for setuptools directories reveals:

/usr/lib/python2.6/site-packages/setuptools-18.0.1.dist-info/

while the setuptools.pth file in /usr/lib/python2.6/site-packages/ contains a pointer to the non-existent ./setuptools-0.6c11-py2.6.egg-info.

At the same time, there is a directory

/usr/share/doc/python-setuptools-0.6.10/

After all this, pip no longer works.

nikosd
  • 909
  • 2
  • 14
  • 25
  • `distribute` is dead. Does removing distribute and installing/upgrading `setuptools` and `pip` solve the problem? – cel Jul 15 '15 at 18:31
  • Have you tried http://stackoverflow.com/questions/7446187/no-module-named-pkg-resources ? – juanmajmjr Jul 15 '15 at 18:34
  • @cel Trying to uninstall `distribute` resulted in the same error. Looking into it.. – nikosd Jul 15 '15 at 18:36
  • @nikosd, I usually recommend anaconda, because it makes things so simple. If you do not want to use anaconda, I would at least use a `virtualenv`. This issue could be caused by a fight between your package manager and pip - `using sudo` for `pip` is in most cases a bad sign :) – cel Jul 15 '15 at 18:48
  • @cel, agreed, eventually everything will be in a `virtualenv` due to `Flask`. I'll try that. – nikosd Jul 15 '15 at 18:52
  • 1
    @juanmajmjr The accepted answer from http://stackoverflow.com/questions/7446187/no-module-named-pkg-resources did not work either. Trying to remove `distribute` as described here https://pypi.python.org/pypi/setuptools/0.9.8#installation-instructions – nikosd Jul 15 '15 at 18:52

3 Answers3

3

@pavan they said CentOS, so apt is unlikely to help them.

They could, though, do :

yum remove python-setuptools

yum install python-setuptools  

(my also need to reinstall pip: yum install python-pip )

And that might fix the problem.

Book Of Zeus
  • 48,229
  • 18
  • 169
  • 166
user41734
  • 31
  • 4
  • The project this was meant for has been happily decommissioned, so I do not have access to that CentOS machine any more. I will try it next time such an approach is needed, in the meantime someone else might be able to check if reinstalling python-setuptools fixes the problem. – nikosd Nov 19 '15 at 17:14
1

Try this for OS supporting apt-get (Ubuntu etc)

sudo apt-get install python-pkg-resources python-setuptools --reinstall

Pavan Kumar N
  • 297
  • 1
  • 4
  • 17
0

Try install python-pip (and dependencies):

yum install python-pip

This solved my problem (Centos release 6.8).