1

I know that installing python packages using sudo pip install is bad a security risk. Unfortunately, I found this out after installing quite a few packages using sudo.

Is there a way to find out what python packages I installed using sudo pip install? The end goal being uninstallment and correctly re-installing them within a virtual environment.

I tried pip list to get information about the packages, but it only gave me their version. pip show <package name> gave me more information about an individual package such as where it is installed, but I don't know how to make use of that information.

peachykeen
  • 4,143
  • 4
  • 30
  • 49
  • Well, my guess is, you did `sudo pip install` whenever you were installing site packages and not in a virtualenvironment. I'd start by getting rid of any site packages. – Athena Oct 05 '18 at 16:38
  • As @Ares suggested, I would just purge all packages in the list and reinstall them, `pip uninstall ` – artomason Oct 05 '18 at 16:42
  • Have you tried the `which` command? – NerdOfCode Oct 05 '18 at 16:43
  • @NerdOfCode I have not tried which. How would one use that command to achieve this? artomason and Ares I am sharing this machine with some other users, so I want to avoid just purging everything because it might purge some of their stuff. – peachykeen Oct 05 '18 at 16:46
  • Disregard my comment. – NerdOfCode Oct 05 '18 at 16:49

3 Answers3

1

When you run sudo pip install, pip will install the package in your global site-packages directory.

So, to determine which packages you've installed with sudo pip install, you can navigate to your /site-packages directory.

The site-packages directory is a sub-directory of your python installation. For example, /Users/me/Library/Python/2.7/lib/python/site-packages.

This SO post has a more detailed discussion regarding how to find the site-packages directory.

Hope this helped!

Matt Hahn
  • 394
  • 1
  • 4
  • 13
1

any modules you installed with sudo will be owned by root, so you can open your shell/terminal, cd to site-packages directory & check the directories owner with ls -la, then any that has root in the owner column is the one you want to uninstall.

deadvoid
  • 1,270
  • 10
  • 19
0

try the following command: pip freeze

user2953680
  • 564
  • 1
  • 5
  • 16
  • The question is about distinguishing `sudo pip install` from `pip install`. How does `pip freeze` help in distinguishing? – phd Oct 06 '18 at 01:20