I was trying to install Python packages a system I recently gained access to. I was trying to take advantage of Python\'s relatively new per user site-packages directory, an
Posting to save others time, as no available answers worked for me...
In some environments, using the --target
(-t
) switch will still hit the same error. In my testing on two flavors of linux, I encountered the same issue when using the --prefix=
parameter.
Code:
PYTHONUSERBASE=/tmp/ pip install --user --force-reinstall $PACKAGE
Explanation:
My workaround, which seems to work across many environments (MacOS, Amazon Linux, Debian) is to set the PYTHONUSERBASE
environment variable to a temp location. --force-reinstall
is used to trigger the local installation even when the package is already installed.
This will result in the module being compiled/installed (depending on the OS and Python version) to: /tmp/lib/python2.7/site-packages/*