How do I make Python 3.5 my default version on MacOS?

后端 未结 7 2312
迷失自我
迷失自我 2020-12-28 10:46

I have just installed Python 3.5.1 on my Mac (running the latest version of OSX). My system came with Python 2.7 installed. When I type IDLE at the Terminal pro

7条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-28 11:06

    Do right thing, do thing right!

    1. Open your terminal,

    2. input python -V, It likely shows:Python 2.7.10

    3. input python3 -V, It likely shows:Python 3.7.2

    4. input where python or which python, It likely shows:/usr/bin/python

    5. input where python3 or which python3, It likely shows: /usr/local/bin/python3

    6. add the following line at the bottom of your PATH environment variable file in ~/.profile file or ~/.bash_profile under Bash or ~/.zshrc under zsh.

    alias python='/usr/local/bin/python3' OR alias python=python3

    1. input source ~/.bash_profile under Bash or source ~/.zshrc under zsh.

    2. Quit the terminal.

    3. Open your terminal, and input python -V, It likely shows: Python 3.7.2

    Note, the ~/.bash_profile under zsh is not that ~/.bash_profile.

    The PATH environment variable under zsh instead ~/.profile (or ~/.bash_file) via ~/.zshrc.

    Hope this helped you all!

提交回复
热议问题