11

I upgraded and installed latest Python version 3.8.1.

Problem is, when I type

python --version

on terminal I get Python 2.7.16, when I type

python3 --version

I get Python 3.8.1. But if I try to

pip install -U selenium

I get a message:

"DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support"

I dont understand why is it running on Python 2.7

sinoroc
  • 18,409
  • 2
  • 39
  • 70
EmisV
  • 119
  • 1
  • 1
  • 3
  • 2
    Maybe try `pip3 install -U selenium`, and you can check which version of `pip` you are using by doing `which pip`. – l'L'l Feb 22 '20 at 03:17
  • 1
    pip3 install -U selenium WORKED but when i try to upgrade pip: pip install --upgrade pip i get a message that says: "DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support". what a nightmare! – EmisV Feb 22 '20 at 03:22
  • You just need to make your `pip3` the default if you are using `python 3`. What OS are you using? It's pretty simple to set an alias for it. – l'L'l Feb 22 '20 at 03:33
  • 2
    I did do allias pip=pip3 and it worked! – EmisV Feb 22 '20 at 04:04
  • 1
    I would not recommend using this alias. – sinoroc Feb 22 '20 at 07:00
  • Does this answer your question? [Install numpy on python3.3 - Install pip for python3](https://stackoverflow.com/questions/17443354/install-numpy-on-python3-3-install-pip-for-python3) – Loïc Dec 18 '20 at 10:48
  • 1
    You can use pip like so : ```python3 -m pip install ...``` – Loïc Dec 18 '20 at 10:48

2 Answers2

18

Never call the pip, pip3, or pipX.Y scripts directly unless you really understand what the implications are.

Instead always prefer calling the exact Python interpreter you are targeting and tell it to run pip's executable module:

  • path/to/my/pythonX.Y -m pip
  • path/to/my/python -m pip
  • path/to/venv/bin/python -m pip
  • pythonX.Y -m pip
  • python3 -m pip
  • python -m pip

I recommend reading Brett Cannon's article "Why you should use python -m pip".

sinoroc
  • 18,409
  • 2
  • 39
  • 70
-4

The Python executable is found under the bin directory but the pip executable is under the Scripts directory. Check your path to see which Scripts directory is encountered first ? Most probably it would be the Python 2.7. I encountered the same issue and found that my Python 2.7 Scripts directory was before the Python 3.8 Scripts directory but Python 3.8 bin was before Python 2.7 bin directory in the Path variable.

U13-Forward
  • 69,221
  • 14
  • 89
  • 114
Sagi
  • 322
  • 2
  • 9