pip install -r requirements.txt fails with the exception below OSError: [Errno 13] Permission denied: \'/usr/local/lib/.... What\'s wrong and how d
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
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.