I have already installed numpy successfully and I'm now trying to install matplotlib. I am following the steps found on the following website:
http://matplotlib.org/faq/installing_faq.html#source-install-from-git
The error occurs after the following command:
python setup.py install
Here is the error:
Checking .pth file support in /usr/local/lib/python2.7/dist-packages/
error: can't create or remove files in install directory '
The following error occurred while trying to add or remove files in the installation directory:
[Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/test-easy-install-24752.pth'
The installation directory you specified (via --install-dir, --prefix, or the distutils default setting) was:
/usr/local/lib/python2.7/dist-packages/
I am working as the administrator on my machine and (I think) have all the rights to read/write files:
administrator@ubuntu:/usr/local/lib/python2.7/dist-packages$ ll -a
total 8
drwxrwsr-x 2 root staff 4096 Aug 20 2013 ./
drwxrwsr-x 4 root staff 4096 Mar 9 11:04 ../
What is the problem and how do I fix it?
matplotlibin avirtualenvis rather tricky because of the backend dependencies, which usually need to be installed system-wide. Since the OP is using Ubuntu, probably the easiest way to installmatplotlibis simply$ sudo apt-get install python-matplotlib. If it's absolutely necessary for the OP to build it from source in avirtualenv, then this guide may be helpful.sudocommand actually did the trick thanks. But any idea why it could not create files even though I had all the sufficient permissions?/usr/local/lib/python2.7/dist-packages/- it's almost certainly only writeable byroot. Being logged in as an 'administrator' usually means that you are on thesudoerslist but not that your normal login shell can write to system files (and that's a very good thing!). In general I would strongly recommend againstsudoinstalling Python packages, either usingpip,easy_installorsetup.py. You can get into a real mess because other package managers such asapt-gethave no awareness of any changes made in this way.