默认Mac电脑上安装的Python版本是2.X,众所周知Python3.X和Python2.X互不兼容。默认Mac系统已经安装Python2.7,如果使用Python3.x需要手动安装
一、查看默认版本
localhost:~ sun$ python Python <mark>2.7.10</mark> (default, Jul 15 2017, 17:16:57) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>>
二、安装Python3.x
1.登录Python官网
www.python.org
2.选择下载Python3.x
3.安装Python3.x,Python3.x下载完后为.pkg文件,安装方法和安装其他应用软件一样。
三、查看安装后版本localhost:~ sun$ python3
localhost:~ sun$ python3 Python <mark>3.6.4</mark> (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>>