Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to switch python3 versions on MacOs [duplicate]

I am using python version 3.10.2 but I want to downgrade to 3.9 because it is not compatible with a library in my project. How can I do this with terminal command?

So when I type python3 --version my version is 3.10.2 I want to downgrade it. IDE is pycharm

like image 923
elify Avatar asked Jan 31 '26 02:01

elify


1 Answers

Install pyenv with Homebrew on macOS:

brew update
brew install pyenv

Define your vitual env variables:

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
source ~/.bash_profile
Restart your shell so the path changes take effect

exec "$SHELL"

Check the available python versions:

pyenv install --list

Install the required python version:

pyenv install 3.9

Set it as your global version:

pyenv global 3.9
like image 133
Matei Piele Avatar answered Feb 03 '26 09:02

Matei Piele



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!