【问题标题】:When switching to zsh shell on mac terminal from bash, how do you update the base python version?从 bash 切换到 mac 终端上的 zsh shell 时,如何更新基本 python 版本?
【发布时间】:2020-06-09 11:40:47
【问题描述】:

Mac 最近将其终端 shell 从 bash 更新为 Zsh。作为一名 Python 程序员,我希望所有系统(包括终端和 IDE)的 Python 版本保持一致。

在 bash shell 上,要将终端中的 python 版本更新到 3.8.1,我遵循了以下过程

纳米~/.bash_profile

别名 python=python3

ctrl + x

是的

输入

这使我能够将 python 版本从 2.7.6 更新到 3.8.1。但是,对 zsh shell 重复相同的步骤并没有成功。尝试对上述过程进行调整,并以某种方式卡在 3.7.3

后续步骤

which python3 #Location of the python3.8.1 terminal command file is found。安装好了。

python --version #returned python 3.7.3

PS:我是python的绝对初学者,所以请在您的回复中考虑到这一点。我希望我没有浪费你的时间。

【问题讨论】:

  • 您需要更新环境中的PATH 变量,使用zsh 的配置文件而不是bash 的配置文件。尝试apple.stackexchange.comunix.stackexchange.com 以获取有关如何执行此操作的建议;这不是 Stack Overflow 的主题。
  • alias python=python3 不会更新任何内容。该别名只会导致 shell 将“python”解释为“python3”。

标签: python bash shell terminal zsh


【解决方案1】:

实际上不建议在系统范围内更新默认的 Python 可执行文件,因为某些应用程序依赖它。

不过,您可以使用 venv(虚拟环境)或在 ZSH 中使用其他版本的 Python,您也可以在您的 ~/.zsh_profile 中添加类似 python='python3' 的别名并获取它。

希望对您有所帮助。

问候

【讨论】:

    猜你喜欢
    • 2021-04-07
    • 2017-09-07
    • 2012-02-07
    • 1970-01-01
    • 2015-03-27
    • 2013-07-12
    • 2021-01-05
    • 1970-01-01
    • 2020-08-30
    相关资源
    最近更新 更多