首页 > 解决方案 > 安装3.8后如何防止终端拿起旧的python版本2.7.16

问题描述

我遵循了有关堆栈溢出的所有可能建议,但没有成功。当我运行python --version结果时:

Home-Macbook-Pro:~ pcmac$ python

WARNING: Python 2.7 is not recommended. 
This version is included in macOS for compatibility with legacy software. 
Future versions of macOS will not include Python 2.7. 
Instead, it is recommended that you transition to using 'python3' from within Terminal.

Python 2.7.16 (default, Jun  5 2020, 22:59:21) 
[GCC 4.2.1 Compatible Apple LLVM 11.0.3 (clang-1103.0.29.20) (-macos10.15-objc- on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit ()

请问如何卸载或强制终端使用 Python 3.8 版本 IDLE 也在旧的 Python 版本 2.7.16 上运行

标签: pythonmacos

解决方案


我有同样的问题,这个解决方案对我有用:

我正在使用 macOS Catalina 版本 10.15.6 并使用自制软件安装 python 3.8.5。

我所做的只是在终端中输入“nano .zprofile”,然后输入: alias python='python3' 并通过按 Ctrl+o 然后 Enter 来保存它。


推荐阅读