美文网首页
MAC下更改默认的Python版本

MAC下更改默认的Python版本

作者: 虫yu | 来源:发表于2020-05-06 10:45 被阅读0次

    当前默认版本:

    $ 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.
    >>>
    

    相关文章

      网友评论

          本文标题:MAC下更改默认的Python版本

          本文链接:https://www.haomeiwen.com/subject/xwyightx.html