1.mac本身自带 python 2.7.15
➜ ~ python --version
Python 2.7.15
2.通过homebrew安装 python3
➜ ~ brew install python3
3.CPython是官方的一个python的解释其,装了环境就有了,通过终端启动,exit()退出。
➜ ~ python
Python 2.7.15 (default, Jun 17 2018, 12:46:58)
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
➜ ~
4.如何切换环境,不同的python命令程序在不同的bin目录下,如果要使用python 2
➜ ~ python2
Python 2.7.15 (default, Jun 17 2018, 12:46:58)
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print('hello world')
hello world
>>>
5.如果要使用python3
➜ ~ python3
\Python 3.7.0 (default, Aug 22 2018, 15:22:33)
[Clang 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print('hello world')
hello world
>>>