"PermissionError: [Errno 13] Permission denied: '/usr/lib/python3.5/site-packages'" installing Django

You could accidentally recreate virtualenv with Python2 by forgetting to put path to Python3 interpreter so when you execute pip3 it refers to system Python3.

Make sure that you use correct Python in your virtualenv and also make sure that you create virtualenv with pip (yes it's the default option but we don't know how you create your virtual environment).


Just to expand on the answer by @valentjedi, here's how I got my permission issue fixed without using sudo.

Install

  • Make sure you have virtualenv installed here

  • This is optional, but I also use virtualenvwrapper to use the workon command here, otherwise you can just source bin/activate from the virtualenv

Create Virtualenv

You do not want to install your project libraries with sudo because it will install your libraries system wide (which will run into issues when you have more than one project). Instead use virtualenvs like this:

$mkvirtualenv myenv --python=python3.5
$workon myenv
$pip3 install -r requirements.txt

This gets you setup by making your virtualenv 'myenv' and specifying which python you are using. You then activate the environment and are able to install your requirements file.