python - Python3.8.1 已安装但编译器找不到
问题描述
Python 3.8.1 已安装,但它仍然说版本是 2.7.17。我如何实际使用 3.8.1?
$ brew install python@3.8
Warning: python@3.8 3.8.1 is already installed and up-to-date
To reinstall 3.8.1, run `brew reinstall python@3.8`
$ python --version
Python 2.7.17
解决方案
Homebrew 在python3
;下安装 Python 3 python
除非您明确提出要求,否则它永远不会别名为 Python 3: https ://docs.brew.sh/Homebrew-and-Python#python-3x-or-python-2x
可执行文件的组织方式如下,以便可以安装 Python 2 和 Python 3 而不会发生冲突:
python3
指向 Homebrew 的 Python 3.x(如果已安装)python2
指向 Homebrew 的 Python 2.7.x(如果已安装)python
指向 Homebrew 的 Python 2.7.x(如果已安装),否则指向 macOS 系统 Python。检查brew info python
您是否希望将 Homebrew 的 3.x python 添加到您的 PATH 中。
在brew info python
输出之后,您应该能够通过在您的 中添加以下路径来获得指向 Python 3 的未版本化别名$PATH
:
$(brew --prefix python@3.8)/libexec/bin
也就是说,在您的~/.bash_profile
or中添加以下行~/.bashrc
:
PATH="$(brew --prefix python@3.8)/libexec/bin:$PATH"
启动一个新的 shell,python
应该是 Python 3.8。
推荐阅读
- java - 如何在 Android 的 EditText 中移动光标
- tensorflow2.0 - 将输入张量从 CPU 复制到 GPU 以运行 GatherVe 失败:Dst 张量未初始化。[操作:GatherV2]
- reactjs - 自定义 AmplifySignOut 的布局
- javascript - 如何在javascript中按id嵌套数据过滤和分组?
- c# - 如何在模型 csharp 中使用 DynamicObject
- html - 展开元素“向上”而不是“向下”
- laravel - 是否可以在 Laravel Nova 中自定义右上角的用户菜单?
- python - 如何在 matplotlib 图中使用外部颜色图(例如 plotly)?
- api - 如何制作 POST API URL
- json - 带有流按钮的 SharePoint 列表列上的条件格式