Python: 转换Python默认版本, 设置Python3为默认版本, How to make ‘python’ program command execute Python 3?

 

最简单的方法就是直接修改 ~/.bashrc 或者 ~/.bash_aliases文件,添加如下代码:

alias python=python3

然后运行

source ~/.bash_aliases 
#或者
#source ~/.bashrc

再检查一下版本:

$ python --version
Python 2.7.6
$ python3 --version
Python 3.4.3
$ alias python=python3
$ python --version
Python 3.4.3

想要取消就用:

$ unalias python
$ python --version
Python 2.7.6

 

本文:Python: 转换Python默认版本, 设置Python3为默认版本, How to make ‘python’ program command execute Python 3?

Loading

2 Comments

Add a Comment

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.