我已将python 3更新为最新版本3.8:

brew search python
==> Formulae
app-engine-python   gst-python          python ✔            python@3.8 ✔
boost-python        ipython             python-markdown     wxpython
boost-python3       micropython         python-yq

==> Casks
awips-python               kk7ds-python-runtime       mysql-connector-python

但当我在mac上查看python3版本时,它仍然显示3.7:

python3 --version

Python 3.7.6

如何使用brew 将python3默认为最新的3.8版本?

编辑:

brew switch python 3.8.1
python does not have a version "3.8.1" in the Cellar.
python's installed versions: 3.7.6_1

推荐答案

好的,感谢brew 社区讨论(https://discourse.brew.sh/t/how-to-default-python-3-8-on-my-mac-using-homebrew/7050)中的@gromgit

以下是解决方案:

$ brew info python@3.8
python@3.8: stable 3.8.1 (bottled) [keg-only]
...
==> Caveats
Python has been installed as
  /usr/local/opt/python@3.8/bin/python3
...
python@3.8 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

If you need to have python@3.8 first in your PATH run:
  echo 'export PATH="/usr/local/opt/python@3.8/bin:$PATH"' >> ~/.bash_profile

For compilers to find python@3.8 you may need to set:
  export LDFLAGS="-L/usr/local/opt/python@3.8/lib"

For pkg-config to find python@3.8 you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/python@3.8/lib/pkgconfig"

现在我将坚持使用python(v3.7.6),等待v3的无缝升级.8.1在future 的版本中.

Python-3.x相关问答推荐

如何将从维基百科表中抓取的数据转换为字典列表?

可以在 Python 的上下文管理器中调用 sys.exit() 吗?

CSV-DAT 转换时将引号添加到数据中

如何获取自定义文件上传路径的对象ID?

python3,将整数转换为字节:对于小整数使用 to_bytes() 有哪些替代方法?

Python Regex 查找给定字符串是否遵循交替元音、辅音或辅音、元音的连续模式

Python 3 `str.__getitem__` 的计算复杂度是多少?

Python defaultdict 在获取时返回 None,尽管使用默认值初始化

Tkinter IntVar 返回 PY_VAR0 而不是值

在气流中运行 DAG 时出现处理信号:ttou消息

合并两个numpy数组

ValueError:找不到子字符串,我做错了什么?

Python:如何在三个列表中找到共同值

sys.stdin.readline() 读取时没有提示,返回 'nothing in between'

如果一个失败,如何取消收集中的所有剩余任务?

用 numpy nan 查找列表的最大值

接收导入错误:没有名为 *** 的模块,但有 __init__.py

警告:请使用 tensorflow/models 中的官方/mnist/dataset.py 等替代方案

如何对字典的函数输出列表进行单元测试?

如何在不更改任何默认值的情况下在 Ubuntu 上为 python 3.8 安装 pip?