Skip to content
Advertisement

messed up pip for python 2.7.16 and upgraded it to pip v 21.1.2

specs:

macOs BigSur

Iterm2 with ohmyzsh

preinstalled with python2.7.16 & python 3.9.5

Problem :

i upgraded pip without pyenv , so now both pip and pip3 refer to python 3.9.5

i made an alias for python 3.9.5 to be default in .zshrc file

i also used pip to install flask

Questions :

Do i donwgrade pip for python2.7.16?

Or re install python2.7.16 with its pip?

i know i must have used pyenv but; is it possible now ? after 2 versions already installed?

* system (set by /Users/johnDoe/.pyenv/version)
➜  ~ python2 --version
Python 2.7.16
➜  ~ python3 --version
Python 3.9.5
➜  ~ pip --version
pip 21.1.2 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)
➜  ~ pip3 --version
pip 21.1.2 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)
➜  ~ pip freeze
click==8.0.1
Flask==2.0.1
itsdangerous==2.0.1
Jinja2==3.0.1
MarkupSafe==2.0.1
Werkzeug==2.0.1

➜  ~ where python
python: aliased to /usr/local/bin/python3
/usr/bin/python
➜  ~ where python3
/usr/local/bin/python3
/usr/local/bin/python3
/usr/bin/python3
➜  ~ where pip
pip: aliased to /usr/local/bin/pip3
/usr/local/bin/pip
/usr/local/bin/pip
➜  ~ where pip3
/usr/local/bin/pip3
/usr/local/bin/pip3
/usr/bin/pip3
➜  ~ which pip
pip: aliased to /usr/local/bin/pip3
➜  ~ which pip3
/usr/local/bin/pip3
➜  ~ which python
python: aliased to /usr/local/bin/python3
➜  ~ which python3
/usr/local/bin/python3
➜  ~ which python2
/usr/bin/python2
➜  ~ where flask
/usr/local/bin/flask
/usr/local/bin/flask
➜  ~ which flask
/usr/local/bin/flask

Advertisement

Answer

You should downgrade the pip package of your Python 2 installation as Pip 21.0 dropped supported for Python 2.

For some reason, the pip command on your system refers to the Python 3 installation. One would think there’d be two commands, pip2 and pip3, just as for the Python interpreter.

Therefore, run the following command to downgrade Pip for Python 2 to the last supported version:

python2 -m pip install "pip<21.0"

Here pip is called “as a module” via python2. This makes sure it uses the Pip package manager of the Python 2 installation, and not the (separate) one for Python 3.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement