python - 如何将 python 版本从 3.8 降级到 3.7 (mac)
问题描述
我正在使用 Python 和 okta-aws 工具,为了在 aws 上获取正确的凭据,我需要运行 okta-aws init。但是得到一个错误信息Could not read roles from Okta
并且系统提示那个"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,似乎我下的Pipflie~/Pipfile
和/usr/local/Cellar/python@3.8/3.8.3_2/libexec/bin/Pipfile
都具有相同的python 3.8版本,而我下的Pipfile /usr/local/Cellar/okta-aws-tools/1.1.4/libexec/Pipfile
有required python_version = 3.7
.
我已经为此苦苦挣扎了一段时间,真的不知道如何解决这个问题。
解决方案
考虑pyenv
在 macOS 上使用 Homebrew安装
brew update
brew install pyenv
或克隆存储库以获取最新版本的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,使路径更改生效
exec "$SHELL"
验证安装并检查可用python
版本
pyenv install --list
安装所需python
版本
pyenv install 3.7
安装后将其设置为您的全局版本
pyenv global 3.7
验证python
系统正在使用的当前版本
python3 --version
推荐阅读
- android - 如何使从 android java 发送的电子邮件?
- c# - 如何使用 C# WebAPI .NET Core Entity Framework 修复 Odata
- c++ - 结构定义上的变量初始化调试与发布模式
- c - 如何将一个元素移动到固定数组的左侧
- java - printf()(格式化打印)与普通 print() 相比有什么优势?
- linux - Linux里面是如何执行命令的
- java - 如何使用 POM 在类路径中添加本地 jars 文件夹
- sql - 为什么我的派生表(子查询)不能有别名
- javascript - 如何获得父母的钥匙
- javascript - 使用按钮删除图像