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

前端 未结 21 1962
滥情空心
滥情空心 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:26

    Open ~/.bash_profile file.

    vi ~/.bash_profile
    

    Then put the alias as follows:

    alias python='python3'
    

    Now save the file and then run the ~/.bash_profile file.

    source ~/.bash_profile
    

    Congratulation !!! Now, you can use python3 by typing python.

    python --version
    

    Python 3.7.3

提交回复
热议问题