MAC下更改默认的Python版本
2020-05-06 本文已影响0人
虫yu
当前默认版本:
$ python -V
Python 2.7.16
$ 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, Nov 9 2019, 05:55:08)
[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.
>>>
查看各版本python的路径:
$ which python
/usr/bin/python
$ which python3
/usr/local/bin/python3
修改默认路径:
$ alias python="/usr/local/bin/python3"
查看替换结果:
$ python -V
Python 3.7.1
$ python
Python 3.7.1 (default, Nov 28 2018, 11:51:47)
[Clang 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>