Search code examples
pythonpython-3.xpython-2.7pip

How to upgrade pip to pip3 and switch from python 2.7 to 3


so I have a MacBook Air running 11.2.1 Big Sur

pip --version

returns this output:

pip 20.2.1 from /Library/Python/2.7/site-packages/pip-20.2.1-py2.7.egg/pip (python 2.7)

when I type python into the terminal, it automatically loads python 2.7, and python3 loads python 3.8.2 like its supposed to

I want to install PyQT5 and this version of pip isn't letting me do that, I want to upgrade pip to pip3 and replace python 2 with python 3 in the process.

Can you guys help me upgrade my python and pip? I don't mind losing python or pip 2 completely.


Solution

  • Use python3 interpreter to run the command:

    python3 -m pip install --upgrade --force pip
    

    The -m calls the __main__.py module of a specified package.


    Use pip3 binary directly:

    pip3 install --upgrade --force pip
    

    Valid with: pip -V