Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to downgrade python version from 3.8 to 3.7 (mac)

I'm using Python & okta-aws tools and in order to fetch correct credentials on aws I need to run okta-aws init. But got an error message of Could not read roles from Okta and the system prompted that"Your Pipfile requires python_version 3.7, but you are using 3.8.3 (/usr/local/Cellar/o/1.1.4/l/.venv/bin/python).

I've tried to search all the Pipfiles on the mac and it seems that the Pipflie under my ~/Pipfile and /usr/local/Cellar/[email protected]/3.8.3_2/libexec/bin/Pipfile all have the same python version of 3.8, while the Pipfile under my /usr/local/Cellar/okta-aws-tools/1.1.4/libexec/Pipfile has required python_version = 3.7.

I've been struggling with this for a while and really not sure how I can fix this.

like image 294
user13902742 Avatar asked Jul 14 '20 15:07

user13902742


People also ask

Can I downgrade Python version?

We can remove and install the required version of Python to downgrade it. First, we need to download the package from the official website and install it. Then, we need to go to the Frameworks\Python. framework\Versions directory and remove the version which is not needed.

Does Python 3.7 work on m1 Mac?

yes, so this shows the path as /usr/local/opt/[email protected]/ which you can then use to run that version from - thanks!


2 Answers

Consider installing pyenv with Homebrew on macOS

brew update brew install pyenv 

OR Clone the repository to get the latest version of pyenv

 git clone https://github.com/pyenv/pyenv.git ~/.pyenv 

Define your environment 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" 

Verify the installation and check the available python versions

pyenv install --list 

Install the required python version

pyenv install 3.7 

Set it as your global version after installation

pyenv global 3.7 

Verify your current python version the system is using

python3 --version 
like image 184
Shayan Avatar answered Sep 26 '22 21:09

Shayan


I recommend you to install and use pyenv, a Python Version Management. Once intalled pyenv, install python 3.7:

pyenv install 3.7 

And then set the environment PYENV_VERSION to version of python you want to use, on this case will be 3.7:

pyenv shell 3.7 
like image 20
Nicolas Acosta Avatar answered Sep 23 '22 21:09

Nicolas Acosta