Repair Python3 pip installation on WSL

Viewed 599

I accidentally deleted a directory ~/.local/lib/python3.5/site_packages/pip in my Ubuntu 16.04 installation on WSL.

After this I get errors when running pip3 like

 File "/home/harper/.local/bin/pip", line 7, in <module>
   from pip._internal.cli.main import main
 File "/home/harper/.local/lib/python3.5/site-packages/pip/_internal/cli/main.py", line 60
   sys.stderr.write(f"ERROR: {exc}")

Now I tried to repair this by uninstalling pip3 and python3 and following both packages with apt

sudo apt update
sudo apt upgrade
sudo apt uninstall python3-pip python3
sudo apt install python3 python3-pip

But the command pip3 --version still shows the error message above.

What is the best way to do a clean reinstall of Python3? Is there any cache, probably the ~/.local/lib/python3.5/site_packages/__pycache__ directory that can be cleared or erased?

1 Answers

You still have old pip script in your $PATH which apt cannot override. Remove /home/harper/.local/bin/pip and rehash $PATH with hash -r pip.

Related