I am working as the administrator on my machine and (I think) have all the rights to read/write files
This is really a discussion more suited to SuperUser, but the problem is that being an 'administrator' doesn't really mean what you think it does. In this line:
drwxrwsr-x 2 root staff 4096 Aug 20 2013 ./
root
is the owner of the directory, and the final r-x
means that other users are only allowed to read and execute, not write to this directory (see here for more details).
What can you do?
Run the install command as
root
, e.g.$ sudo python setup.py install
. This is NOT RECOMMENDED! The problem with installing system-wide Python modules in this way is that other package managers (e.g.apt-get
) are totally oblivious to any changes made in this way, which tends to lead to a mess of broken dependencies for other system packages.Install the package from the Ubuntu repositories, i.e.
$ sudo apt-get install python-matplotlib
. This is probably the easiest way to install matplotlib, and is very unlikely to break any dependencies. However, the Ubuntu repositories tend to contain somewhat older versions of most Python packages.Install it into a
virtualenv
. This is safe, in that it doesn't affect anything in your globalsite-packages
, and it allows you to install the very latest bleeding-edge versions. However, installing matplotlib into avirtualenv
can be tricky, since matplotlib has lots of backend dependencies that generally need to be installed system-wide. To work around this you could either:a) Create your
virtualenv
with the--system-site-packages
flag. With this option, if Python tries toimport
a module that isn't installed locally in yourvirutalenv
'ssite-packages
directory, it will then look in the system-widesite-packages
. This means that you can install matplotlib locally in yourvirtualenv
and it will find all of its backend dependencies in the system-widesite-packages
. The downside is that if you have the same module installed both locally and system-wide, you have to be a bit more careful about version is actually being imported.b) Create your
virtualenv
with the--no-site-packages
flag, then make symbolic links to the required modules in your system-widesite-packages
directory. This blog article gives a good set of instructions for installing matplotlib inside avirtualenv
using symlinks. This method is trickier, but the advantage is that yourvirtualenv
is (almost!) completely self-contained, and there can be no doubt about where your moduleimport
s are coming from.