一、Mac Python 环境配置

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
>>>
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容