How to set Python's default version to 3.x on OS X?

前端 未结 21 1672
滥情空心
滥情空心 2020-11-22 07:52

I\'m running Mountain Lion and the basic default Python version is 2.7. I downloaded Python 3.3 and want to set it as default.

Currently:

$ python
           


        
相关标签:
21条回答
  • 2020-11-22 08:30

    This worked for me. I added alias and restarted my terminal:

    alias python=/usr/local/bin/python3
    
    0 讨论(0)
  • 2020-11-22 08:32

    The following worked for me

    cd /usr/local/bin
    mv python python.old
    ln -s python3 python
    
    0 讨论(0)
  • 2020-11-22 08:35

    You can solve it by symbolic link.

    unlink /usr/local/bin/python
    ln -s /usr/local/bin/python3.3 /usr/local/bin/python
    
    0 讨论(0)
  • 2020-11-22 08:35

    I believe most of people landed here are using ZSH thorugh iterm or whatever, and that brings you to this answer.

    You have to add/modify your commands in ~/.zshrc instead.

    0 讨论(0)
  • 2020-11-22 08:37

    The RIGHT and WRONG way to set Python 3 as default on a Mac

    In this article author discuss three ways of setting default python:

    1. What NOT to do.
    2. What we COULD do (but also shouldn't).
    3. What we SHOULD do!

    All these ways are working. You decide which is better.

    0 讨论(0)
  • 2020-11-22 08:37

    If you are using macports, that has a easier way to do:

    run:

    port install python37

    after install, set default:

    sudo port select --set python python37

    sudo port select --set python3 python37

    restart your cmd window, finished.

    0 讨论(0)
提交回复
热议问题