0

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

elify
  • 440
  • 1
  • 7
  • 15
  • Personally, I use `conda` (just install miniconda and a virtual environment with python-3.9 for that project). Do no change system interpreter. The operating system may require python 3.10. (so use a parallel version just for your project, and possibly use a different environment for every project). -- PyCharm and conda are well integrated. PyCharm can use many python versions in parallel (also within the same project) – Giacomo Catenazzi Feb 14 '22 at 08:09
  • Depends on what [package manager](https://stackoverflow.com/q/58218592/10794031) you are using. If you are using and installation of the Python interpreter without virtual environment you'll have to download and install a new Python version. You don't say what kind of venv you are using so there's no way to answer the question. – bad_coder Feb 14 '22 at 10:07

1 Answers1

6

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
Matei Piele
  • 572
  • 2
  • 15
  • thank you for your response I do not understand this kind of codes(below). Will I write to terminal? also what should I write for $HOME? 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" – elify Feb 14 '22 at 08:00
  • I did same thing.. still; pyenv global 3.9.0...... admin@192 aynam % python3 --version...... Python 3.10.2 – elify Feb 14 '22 at 08:03
  • You can also clone the repo to get the latest version of pyenv `git clone https://github.com/pyenv/pyenv.git ~/.pyenv' – Matei Piele Feb 14 '22 at 08:39