5

I'm trying to upgrade matplotlib in Ubuntu 12.04. When I run the command:

sudo pip install --upgrade matplotlib

I get this error:

Downloading/unpacking matplotlib
  Running setup.py egg_info for package matplotlib
    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'.

    (Currently using distribute 0.6.24dev-r0 (/usr/lib/python2.7/dist-packages))
    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'.

(Currently using distribute 0.6.24dev-r0 (/usr/lib/python2.7/dist-packages))

----------------------------------------
Command python setup.py egg_info failed with error code 2
Storing complete log in /home/gabriel/.pip/pip.log

So I run:

easy_install -U distribute

and I get:

Traceback (most recent call last):
  File "/home/gabriel/Enthought/Canopy_32bit/User/bin/easy_install", line 9, in <module>
    load_entry_point('distribute', 'console_scripts', 'easy_install')()
  File "/home/gabriel/Enthought/Canopy_32bit/User/lib/python2.7/site-packages/setuptools-0.9.8-py2.7.egg/pkg_resources.py", line 378, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/home/gabriel/Enthought/Canopy_32bit/User/lib/python2.7/site-packages/setuptools-0.9.8-py2.7.egg/pkg_resources.py", line 2565, in load_entry_point
    raise ImportError("Entry point %r not found" % ((group,name),))
ImportError: Entry point ('console_scripts', 'easy_install') not found

So there's something not working with my Canopy install. I'm using Spyder right now so I could uninstall Canopy to see if that helps, but the commands sudo apt-get remove enthought* and sudo apt-get remove canopy* find nothing to remove.

What can I do to upgrade matplotlib?


Add

I followed the instructions to remove Canopy from here and now when I run easy_install -U distribute I get:

Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site

which I believe is related with me deleting the line source ~/Enthought/Canopy_64bit/User/bin/activate from ~/.profile. I tried running the following commands as sudo:

apt-get autoclean
apt-get clean
apt-get update
apt-get upgrade
apt-get dist-upgrade
apt-get -f install
dpkg --configure -a
apt-get install --reinstall python

but that did not work. Any ideas on how to fix this?


Add 2

I tried setting PYTHONHOME with the command:

export PYTHONHOME=/usr/lib/python2.7

and now easy_install -U distribute returns:

ImportError: No module named site

Same thing with:

export PYTHONHOME=/usr/local/lib/python2.7

So now off to chase that error.


Add 3

Setting:

export PYTHONHOME=/usr/lib/python2.7/

and then running the command as sudo:

sudo easy_install -U distribute

did the trick. I could then run sudo pip install --upgrade matplotlib. I'll add this as an answer in a minute.

Gabriel
  • 40,504
  • 73
  • 230
  • 404
  • well.. you could just re-download it http://matplotlib.org/downloads.html and install it manually – sihrc Aug 05 '13 at 17:38
  • remove the `source ....` in `.profile`, log out and log in again. You need to re-set your environmental variables. – tacaswell Aug 05 '13 at 18:46

1 Answers1

5

After removing Canopy I run:

export PYTHONHOME=/usr/lib/python2.7/
sudo easy_install -U distribute
sudo pip install --upgrade matplotlib

I could upgrade matplotlib that way.

Gabriel
  • 40,504
  • 73
  • 230
  • 404
  • I did this and now I get `ImportError: No module named os` whenever I try to run `python` from the command line. What happened? Please help. – BoltzmannBrain Feb 16 '15 at 04:14
  • @alavin89 you are getting that error because somewhere in your code you have the line `import os` and your python installation is probably broken. Try here: http://stackoverflow.com/questions/12320143/python-importerror-no-module-named-os – Gabriel Feb 16 '15 at 15:12
  • 1
    Thank you @Gabriel, I figured it out, answer posted here: http://stackoverflow.com/questions/28534506/python-importerror-no-module-named-os?noredirect=1#comment45388102_28534506 – BoltzmannBrain Feb 16 '15 at 17:18