I do recommend using pyenv
for various python installations and better version management. Also, pyenv
is indicated for users who don’t want to temper with the system’s already installed Python.
What is pyenv?
Pyenv is a single-purpose tool that does one thing well. It lets you easily switch between multiple Python versions or easily set up a different Python version globally.
Installation of pyenv
Using Homebrew
brew update
brew install pyenv
Using the automatic installer
The automatic installer is found here https://github.com/pyenv/pyenv-installer.
Install a new Python version using pyenv
List all available Python versions and pick one
pyenv install -l
Install chosen Python version and set it as global
pyenv install 3.10.2
pyenv global 3.10.2
Verify the installation
If everything works, checking your Python version will output the previously installed version.
python3 --version
Different Python version than the one installed from pyenv
If it does not work, and the output differs, you have to override the Python version installed in the system by executing the following commands:
echo 'eval "$(pyenv init --path)"' >>~/.profile
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
Verify the installation again
Open a new terminal and check the Python version again by using python3 --version
.