Home > Back-end >  Competing Python versions
Competing Python versions

Time:03-07

On my Mac, I have 2 versions of Python running, one from Brew (3.9) and another one (3.8) When I try to install some data science packages via pip3, they are installed but cannot be used as 3.9 takes over.

python3 --version Python 3.9.10

which python3 /opt/homebrew/bin/python3

pip3 install pandas Requirement already satisfied: pandas in /Library/Python/3.8/site-packages

python3

import pandas ModuleNotFoundError: No module named 'pandas'

pandas is just one example of the many packages I see via pip3 freeze.

What are my options to point to installed versions at Python 3.8 ?

CodePudding user response:

There are different ways to approach this:

  1. One temporary option is to use alias like this:

    alias python3=python3.8

  2. You can use directly python3.8 in your terminal.

  3. If you want to install the packages to python3.9 then you can also use pip3.9

  4. You could use:

    python3 -m pip install module

which will use pip to install to the python version you just used.

The recommended way is to use:

python3 -m pip install module
  • Related