问题
I am trying to make Python 3.4.2 the default in Linux (currently it is 2.7.6). I am not very knowledgeable on this stuff, but I have read in several places online that you can simply put an alias in the ~/.bashrc
or ~/.bash_aliases
file like this:
alias python='python3'
I don't have either the ~/.bashrc
or ~/.bash_aliases
file . . . I am assuming you can just create them. I have done that, but the alias doesn't seem to be working. Am I missing something? Do you need the shebang at the beginning of the file? I have tried it both ways.
Thanks for any help you can give!
回答1:
DON'T DO IT!
Some linux utilities depend on python2.x
currently. It will probably break your system if you make that change since python3.x
is not backward compatible with python2.x
. Unless you are fully aware of the consequences, don't do it!
Similar question is asked here : https://askubuntu.com/questions/103469/how-do-i-change-my-pythonpath-to-make-3-2-my-default-python-instead-of-2-7-2
来源:https://stackoverflow.com/questions/27789972/bash-alias-python-2-7-to-python-3-3