前言:mac系统自带python,不过以当前mac系统的最新版本为例,自带的python版本都是2.X版本,虽然不影响老版本项目的运行,但是python最新的3.X版本的一些语法与2.X版本并不相同,网上的教程大神们也肯定都更新出了最新版的教程,我们不论是学习还是使用,当然用最新版会更好一点。
我的电脑是MacBook Air,系统版本是最新的macOS Catalina 10.15.1
一、熟悉系统自带的python
在安装最新版Python3.X之前,我们先熟悉一下系统自带的python。
打开终端,输入:
$ 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, Oct 17 2019, 17:14:30)
[GCC 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.32.4) (-macos10.15-objc-s on darwin
Type "help", "copyright", "credits" or "license" for more information.
翻译下前面三句话:
这个版本包含在macOS中,以便与遗留软件兼容。
macOS的未来版本将不包括Python 2.7。
相反,建议您从终端内部过渡到使用’python3’。
二、开始安装Python
1、安装homebrew
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
==> This