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.

Safaetul Ahasan Piyas
  • 1,285
  • 1
  • 8
  • 10
  • 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](https://docs.python.org/3.7/tutorial/venv.html). – Joachim Lusiardi Feb 25 '20 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. – Savannah Madison Sep 06 '21 at 13:12

3 Answers3

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.

Charnel
  • 4,222
  • 2
  • 16
  • 28
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

robins_
  • 57
  • 5
-2

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

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

Giulio
  • 150
  • 2
  • 11
  • 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 Feb 25 '20 at 12:18
  • 2
    I advise against installing package as root (see https://stackoverflow.com/questions/21055859/what-are-the-risks-of-running-sudo-pip). A better way should be `pip install --user djangorestframework`. – Joachim Lusiardi Feb 25 '20 at 12:19