Is there any way to check/de-cruft/update Python packages installed using pip?

Matt Wheeler funkyhat at gmail.com
Tue Dec 29 13:43:39 EST 2020


On 29 Dec 2020, 14:48 +0000, Chris Green <cl at isbd.net>, wrote:
> I seem to have quite a lot of old python packages installed over the
> years using pip and would like, if I can. to clear some of them out.
>
>
> Is there any way to tell if a python package was installed by me
> directly using pip or was installed from the [x]ubuntu repositories?
> 'pip list' just tells me every python package that's installed and
> this really isn't much help.
>
>
> Can one uninstall older versions? For example I seem to have
> three versions of Click installed:-
>
> /usr/local/lib/python2.7/dist-packages/click
> /usr/local/lib/python3.7/dist-packages/click
> /usr/lib/python3/dist-packages/click

Everything under one of these directories comes from apt/dpkg packages.
Packages installed using pip will be installed in a directory called site-packages, not dist-packages

To confirm this you can try the command `dpkg -S <path>`, which will tell you which package a file belongs to

<snip>
>
> If one updates a package using pip will it move it as appropriate from
> (for example) /usr/local/lib/python3.7 to /usr/local/lib/python3.8?

No, each version of pip will completely ignore any packages installed for a different version of Python
> Can pip (or some other tool) tell me what other python packages depend
> on one I'm considering uninstalling?

pipdeptree can do this
> If there are any tools/utilities one can install to check these things
> out I'd love to know about them.
>
> --
> Chris Green
> ·
> --
> https://mail.python.org/mailman/listinfo/python-list


More information about the Python-list mailing list