Help needed about VersionConflict pkg_ressources

on xubuntu 20.04 I upgraded the pip version by doing sudo python3 -m pip install --upgrade pip
Now when I do pip freeze I get the following exception :
pkg_resources.VersionConflict: (pip 22.2.2 (/usr/local/lib/python3.8/dist-packages), Requirement.parse(‘pip==20.0.2’))

pkg_resources.DistributionNotFound: The ‘pip==20.0.2’ distribution was not found and is required by the application

Running pip using sudo is strongly discouraged in the pip documentation, precisely because it can break your system. You should have upgraded your system pip using your distribution’s package manager (if they don’t have the latest version of pip yet, and that matters to you, you’d need to check with them when they will have it packaged). Or use virtual environments, which is the recommended approach.

Now that you have a broken system, the discussions in might help you - the pip developers don’t support this situation, but there’s lots of suggestions in there as to how you can diagnose and resolve the breakage for yourself. Even though that issue is not directly related to the problem you’re seeing, the advice is general.

(My suspicion here is that the distribution-managed /usr/bin/pip is confused because you installed a new version of pip that the script didn’t expect. Reinstalling your distro pip might fix the problem, but as with any time you’re hacking system managed files, please take a backup first so you don’t end up making things worse by mistake!)

1 Like

Thanks for your answer. I kwew about not changeing the system pip version but I was mistaken by a recommendation saying that on ubuntu it wad fine as long as you didt not delete the apt pip version!..
Toobad for me!..

Solved by doing sudo apt purge python3-pip

1 Like