2

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
  • 1
    try with: sudo pip2.7 install numpy Commented Nov 28, 2016 at 23:33
  • Also have a look at virtualenv. It will help you if you have multiple versions of python installed on the same machine. Commented Nov 29, 2016 at 1:40

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.