1
votes

I have installed Anaconda3 to get all the modules for python 3. However there are some codes which must be run in python 2. I don't have any installed python 2 module. I tried installing numpy via:

pip2.7 install numpy

But got an error:

OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/numpy'

Whenever I want to install a module I get the same error, for instance, with the NLTK module I get

OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/nltk-3.2.1.dist-info'

How can I fix this?

Thanks!

2
try with: sudo pip2.7 install numpy - eyllanesc
Also have a look at virtualenv. It will help you if you have multiple versions of python installed on the same machine. - user6307701

2 Answers

1
votes

If you don't have sudo or otherwise proper permissions, you might try installing in a user-writable directory via the "user" flag:

pip2 install --user numpy

The location is customizable with the PYTHONUSERBASE variable. Read all about it (and more) here: https://pip.pypa.io/en/stable/user_guide/#user-installs

1
votes

That's a permission error as your user is not allowed to write to /usr/local/lib/.

try

sudo pip2 install XYZ

or even better: use a virtualenv http://docs.python-guide.org/en/latest/dev/virtualenvs/ It keeps your system clean and you can install & update modules as a normal user.