Ask Different Asked by fsa4 on February 5, 2021
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)?
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
Answered by Rakib Fiha on February 5, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP