1

I originally installed python3-pip through apt and made the mistake of installing packages with sudo instead of as a user installation. I was getting a myriad of errors with tracebacks and import errors, so I am trying to completely remove pip from my system and start fresh.

However, even after uninstalling all my pip packages and a apt purge python3-pip,

  • pip, pip3, and pip3.6 still show up in my tab-complete suggestions when I hit tab (on a new shell, after a restart).
  • I have found a few python stub scripts in ~/.local/bin/:
    • ~/.local/bin/pip
    • ~/.local/bin/pip3
    • ~/.local/bin/pip3.6

These scripts are only ~10 lines each and just have imports for pip. However, when I moved these files out of this directory and reinstalled with apt install python3-pip, these files are not remade during installation.

I am confused what's going on, and what kind of hierarchy pip uses; it all seems a bit cryptic to me. What is the purpose of ~/.local/bin/ and why does pip3 populate it with scripts, but only sometimes?

What can I do to ensure that pip3, along with ANY changes made after I installed/used it, are removed/reverted?

2
  • can u please tell me what problems you are facing and what you are trying to do? – rhoitjadhav Mar 19 '19 at 17:29
  • Not a direct answer as such, but I recommend you take a look at Pipenv, it helps avoid a lot of this type of confusion: docs.python-guide.org/dev/virtualenvs – robosnacks Mar 19 '19 at 17:33
1

After looking into it further, I learned that bash sometimes caches scripts in the PATH and puts it in ~/.local/bin. As a result, even after an apt purge, programs are seemingly still these when the user attempts to tab-complete.

You can check if something is being hashed with:

$ type pip3

and you can clear hashes with

$ hash -d pip3

or

$ hash -r
3
  • 1
    AFAIK, Bash doesn't put anything in ~/.local/bin. Maybe you did a pip3 install --user --upgrade pip. – wjandrea Mar 19 '19 at 18:27
  • Yes, I did! Do you know why it puts it in ~/.local/bin/? – abdl-dev Mar 21 '19 at 0:09
  • 1
    Yes, explanation here: stackoverflow.com/a/42989020/4518341 – wjandrea Mar 21 '19 at 0:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.