python - 如何准备好在 Mac 上使用 python 3.X?

标签 python macos development-environment

我在 OS X 上下载了 python 3.2,然后安装在我的硬盘上。但问题是,当我进入终端时,我输入 python... 它仍然像这样显示旧版本:

Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) [GCC 4.2.1 (Apple Inc. build 5646)] on darwin Type "help", "copyright", "credits" or "license" for more information.

然后,我去python下的文件夹,我找到一个这样的文件:

Update Shell Profile.command

所以,我运行它,它显示类似的东西

/Applications/Python\ 3.2/Update\ Shell\ Profile.command ; exit;
Users-MacBook:~ User$ /Applications/Python\ 3.2/Update\ Shell\ Profile.command ; exit;
This script will update your shell profile when the 'bin' directory
of python is not early enough of the PATH of your shell.
These changes will be effective only in shell windows that you open
after running this script.
All right, you're a python lover already
logout

[Process compleUser]

但我仍然无法在我的终端中获取 python 3.2。我做错什么了吗?谢谢。

最佳答案

在您的终端中,输入 python3

在unix like系统上,python 2.x一般是系统默认使用的python版本。但是 python 2 和 python 3 之间的语言语法发生了巨大变化,使得 2 不兼容。因此,您不能在您的系统上用 python 3 替换 python 2,否则您可能会完全破坏一些重要的系统包。

因此可以通过 python3 命令使用 python 3 解释器,以区别于旧的 python 2 解释器。

关于python - 如何准备好在 Mac 上使用 python 3.X?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7944533/

相关文章:

python - 当 key 明显存在时,为什么我会收到 KeyError?

python - Seaborn 的颜色强度错误

macos - 枚举 Mac 钥匙串(keychain)中的所有证书并比较创建/到期日期

macos - assembly - macOS 上 `.text` 和 `.section __TEXT` 之间的区别?

language-agnostic - 是否有人使用虚拟化来创建更快的开发环境灾难恢复?

python - 如何将列表列表中的元素转换为小写?

python - 在 tensorflow 中更新张量

macos - 在 MacOS Mountain Lion 中使用 yasm 的简单 asm 程序

ruby-on-rails - 在开发环境中 boost Rails 应用程序?

java - 在同一个开发团队中使用不同的 IDE