2

My Mac Mini M1 shipped with Python 3.8.5.

I first installed Anaconda, then downloaded Python 3.9.1 (macOS 64-bit universal2 installer), installed that and ran Update Shell Profile.command.

IDLE runs the correct version (3.9.1) however typing python3 --version at command line yields: Python 3.8.5

where python3 results in the following:

/Users/fa/opt/anaconda3/bin/python3 /Library/Frameworks/Python.framework/Versions/3.9/bin/python3 /usr/local/bin/python3 /usr/bin/python3

How do I get the shell to point to the most recent version (3.9.1)?

4
  • What is the output of ‘which python3.9’ ? And why don’t you use python3’s built in venv or python module pyvenv to manage all the versions ?
    – Rakib Fiha
    Jan 8, 2021 at 4:56
  • which python3.9 outputs /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 how do I utilize vent's to direct it to the correct path? sorry, a little new to this.
    – fsa4
    Jan 8, 2021 at 5:00
  • If you are using conda use conda rather than venv to control things. However that is. Not the issue here. Have you tried in a new terminal which and where should give the same answer. So the first thing to rule out is has the shell cached some information
    – mmmmmm
    Jan 8, 2021 at 9:37
  • See apple.stackexchange.com/q/410284/237
    – mmmmmm
    Jan 8, 2021 at 10:48

1 Answer 1

1

You can use pyenv to manage your python3 versions installed on your system.

To install pyenv:

You can do the following:

# if you dont have homebrew already, install it by:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# install pyenv with homebrew
brew install pyenv
# source pyenv in your .bash_profile if you are using bash
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
# source pyenv in your .zshrc if you are using zsh
echo 'eval "$(pyenv init -)"' >> ~/.zshrc

Open a new terminal or source your bash_profile or shell profile by: source ~/.bash_profile or source ~/.zshrc.

Now to install a new version, you can check the list by:

pyenv install -l | grep anaconda

Find the version you want to install, and install it by:

pyenv install <python-version-to-install>

Now you will be able to see all the different python versions that you have installed by:

pyenv versions

You can choose any of the above output as your global Python from the previous command by:

pyenv global <your-installed-version>

For more details see their git repo at: https://github.com/pyenv/pyenv

1
  • thank you for your help!
    – fsa4
    Jan 8, 2021 at 5:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .