Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: No module named pkg_resources on installing matplotlib

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.

like image 535
nikosd Avatar asked Jul 15 '15 18:07

nikosd


2 Answers

@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.

like image 99
user41734 Avatar answered Sep 28 '22 23:09

user41734


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

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

like image 28
Pavan Kumar N Avatar answered Sep 29 '22 00:09

Pavan Kumar N