Just clarifying what worked for me after much pain in linux (ubuntu based) on permission denied errors, and leveraging from Bert's answer above, I now use ...
$ pip install --user <package-name>
or if running pip on a requirements file ...
$ pip install --user -r requirements.txt
and these work reliably for every pip install including creating virtual environments.
However, the cleanest solution in my further experience has been to install python-virtualenv
and virtualenvwrapper
with sudo apt-get install
at the system level.
Then, inside virtual environments, use pip install
without the --user
flag AND without sudo
. Much cleaner, safer, and easier overall.