2

When I run:

pip install djangorestframework

I got this error message:

ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/usr/local/lib/python3.6/dist-packages/asgiref' Consider using the --user option or check the permissions.

2
  • Hello, this is a pretty common error in the usage of pip, I guess. Use the suggested --user to install the package in your home directory or use a virtualenv. Commented Feb 25, 2020 at 12:13
  • If you are already using an virtual env on ubuntu and if you get this error,then navigate to your virtual env folder.If you see a lock symbol Then you don't have the appropriate permission as a user to pip install inside this.Hence change the permission of the venv folder using this command: sudo chown -R $USER path/to/venv Now switch to the venv and install your package. Commented Sep 6, 2021 at 13:12

3 Answers 3

1

You simply have not enought permissions to install library to user dir. Consider using virtual environment instead of installing all modules in your local Python repository.

0

Use sudo pip install djangorestframework . sudo basically makes you a superuser with privileges to install new packages, you can read about it here in detail

-2

Just add 'sudo' and it should work: sudo pip install djangorestframework

It missing permission to open the asgiref file. Prob a solution here

2
  • 2
    You should carefully advice to use sudo because of security reasons. It's easy to make a mistake a accidentally install something else then you expect and have much bigger problems.
    – Charnel
    Commented Feb 25, 2020 at 12:18
  • 2
    I advise against installing package as root (see stackoverflow.com/questions/21055859/…). A better way should be pip install --user djangorestframework. Commented Feb 25, 2020 at 12:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.