Use the below to install python libraries that “normally” would be installed in a system directory such as /usr/local/lib/pythonX.Y
. Use the --user
flag with the pip
tool to install to a directory you have control over as a user. Here are more details:
--user
installs in the directory specified in site.USER_SITE
~/.local/lib/pythonX.Y/site-packages
~/.bash_profile
file):export PATH=$PATH:~/.local/lib/pythonX.Y/site-packages
Here is an example:
pip install --user mypackage
An alternative to this is to use python virtual environments
Sources: