如何将 python 版本从 3.8 降级到 3.7 (mac) [英] How to downgrade python version from 3.8 to 3.7 (mac)

查看:854
本文介绍了如何将 python 版本从 3.8 降级到 3.7 (mac)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Python &okta-aws 工具,为了在 aws 上获取正确的凭据,我需要运行 okta-aws init.但是收到无法从Okta读取角色的错误消息,系统提示您的Pipfile需要python_version 3.7,但您使用的是3.8.3(/usr/local/Cellar/o/1.1.4/l/.venv/bin/python).

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).

我尝试在 mac 上搜索所有 Pipfiles,似乎我的 ~/Pipfile/usr/local/Cellar/python@3.8/3.8 下的 Pipflie.3_2/libexec/bin/Pipfile的python版本都是3.8,而我的/usr/local/Cellar/okta-aws-tools/1.1.4/libexec/Pipfile下的Pipfilecode> 有 required python_version = 3.7.

I've tried to search all the Pipfiles on the mac and it seems that the Pipflie under my ~/Pipfile and /usr/local/Cellar/python@3.8/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.

推荐答案

考虑在 macOS 上使用 Homebrew 安装 pyenv

Consider installing pyenv with Homebrew on macOS

brew update
brew install pyenv

OR 克隆存储库以获取最新版本的 pyenv

OR Clone the repository to get the latest version of pyenv

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

定义环境变量

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

重启你的 shell 使路径更改生效

Restart your shell so the path changes take effect

exec "$SHELL"

验证安装并检查可用的python版本

Verify the installation and check the available python versions

pyenv install --list

安装所需的python版本

pyenv install 3.7

安装后设置为全球版

pyenv global 3.7

验证系统正在使用的当前python版本

Verify your current python version the system is using

python3 --version

这篇关于如何将 python 版本从 3.8 降级到 3.7 (mac)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆