Search code examples
pythonpipanaconda

different pips are used between `pip --version` and `which pip`


Here's something weird happening on my box:

(base) ben@Ben:~/.local/bin$ echo $PATH
/home/ben/.local/bin:/home/ben/anaconda3/bin:/home/ben/anaconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
(base) ben@Ben:~/.local/bin$ which -a pip
/home/ben/anaconda3/bin/pip
(base) ben@Ben:~/.local/bin$ pip --version
pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7)
(base) ben@Ben:~/.local/bin$ /home/ben/anaconda3/bin/pip --version
pip 20.0.2 from /home/ben/anaconda3/lib/python3.7/site-packages/pip (python 3.7)

Why are different instances of pip were called? which pip returned the correct version that I want, but when I call pip, it runs the one installed by default in the system. How do I fix it?

I have Ubuntu 19.10, Anaconda 4.8.3, Python 3.7.6.


Solution

  • which cannot detect aliases and since your pip points to the system python3 instead of python2, I suspect that you have an alias in your .bashrc for pip. Delete that and it should work as expected.