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

Chris Green cl at isbd.net
Tue Dec 29 16:02:48 EST 2020


Matt Wheeler <funkyhat at gmail.com> wrote:
> 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 
> 
Aaaahhhhh!!!!  :-)   I hadn't realised *that* was the significance of
dist-packages and site-packages, thank you very much, that helps a
huge amount.


> <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 

Again something I hadn't really understood before but obvious when you
think about it.  Thank you again.

-- 
Chris Green
·


More information about the Python-list mailing list