Due to my entire Python environment getting messed up today and scaring me half to death, I really want to clean up my Python environment to its original condition and start using virtualenvs for everything. This is easy for Python 3.5, since it's not crucial and dangerous to just delete the whole folder (I think...), but I know that OSX relies on some Python 2.7 stuff so I'm a little afraid to just go in there and uninstall everything. There's a lot of questions on here that refer to conda-installed packages, but is there anyway I can remove all the stuff I installed via (sudo, why did I do this to myself) pip when I was much sillier and didn't know what a virtualenv was?
Asked
Active
Viewed 606 times
1
-
`pip uninstall`? – Mad Physicist Sep 25 '18 at 01:13
-
So what I've done so far is `pip2 freeze > uninstall.txt` and then run `pip uninstall -r uninstall.txt`, but some of these packages have names that look not-so-safe to delete, so I stopped after uninstalling some obvious ones like scipy, numpy, Flask, etc. Are all of these going to be pip-installed packages? – mudkipium Sep 25 '18 at 01:14
-
It looks like you're doing the right thing. Yes, you can uninstall `scipy`, `numpy`, and `Flask`. Python will work just fine without them. Of course, that means you won't be able to use `numpy`, `scipy`, or `Flask`, but you can always reinstall them. – Matt Messersmith Sep 25 '18 at 01:16
-
Alright, I guess I'll just go for it—thanks! – mudkipium Sep 25 '18 at 01:21
-
The other advantage of having that file is that you'll know what to reinstall when the time comes. – Mad Physicist Sep 25 '18 at 02:41
-
Before you uninstall something, check with your system package manager to see if a system package owns that file/folder. That'll make it much safer. – Mad Physicist Sep 25 '18 at 02:42
-
Don't worry about removing anything shipped with the system - MacOS won't let you do it anyway without heavy system modifications, so you won't break anything even if you wanted to. If you need a quick one-liner: check out [this answer](https://stackoverflow.com/a/52461721/2650249) for a command that deletes every package installed with `sudo` for system python. – hoefling Sep 25 '18 at 06:31
-
Beware that a simple `pip2 freeze` will also list packages you won't be able to uninstall, so `pip uninstall`ing with break on first error. – hoefling Sep 25 '18 at 06:42
-
Oh @hoefling that's great! Thank you! – mudkipium Sep 25 '18 at 12:49