I've installed a couple of pip packages as sudo. As a result pip requires me to enter my password when upgrading or removing installed packages. Is there a simple way to move all packages to the local site, such that I don't need to bother about sudo anymore?
Asked
Active
Viewed 44 times
0
-
1Possible duplicate of [How can I install packages in my $HOME folder with pip?](http://stackoverflow.com/questions/7143077/how-can-i-install-packages-in-my-home-folder-with-pip) – metatoaster Mar 04 '16 at 00:43
2 Answers
1
pip install --user package_name
Should also work with setup.py
files.
python setup.py --user install
And, just in case you want it, within a script.
import pip
pip.main(["install", "--user", "package_name"])

Goodies
- 4,439
- 3
- 31
- 57
1
I'm not sure exactly what you mean by "local site", however I assume you mean virtualenv.
You can use pip freeze > requirements.txt
to get a list of all installed packages, and then use sudo pip uninstall -r requirements.txt
to remove all the packages from the system directory. Then setup and activate your virtualenv, and pip install -r requirements.txt
to get them all installed in your virtualenv.

Cathy
- 515
- 7
- 23