在Unbuntu系统下,安装了python2.7和python3.6
在正常用户模式下,输入如下命令:
python --version , 或者python
会显示当前使用的python版本号
按照目前网上多python版本切换的方案,使用
update-alternatives --config python
的方式,在root模式下可以正常切换,但是在当前用户模式下无法完成切换。
所以翻遍了网上的资料,在用户模式下,直接vi ~/.bashrc
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.if [ -f ~/.bash_aliases ]; then. ~/.bash_aliases
fi# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; thenif [ -f /usr/share/bash-completion/bash_completion ]; then. /usr/share/bash-completion/bash_completionelif [ -f /etc/bash_completion ]; then. /etc/bash_completionfi
fiexport REPO_URL='http://192.168.100.209:8080/git-repo'
alias python=python2
alias python=python2 这里,修改成python2,或者python3
保存之后,source ~/.bashrc,再次运行python,则python版本跟着修改一起变化。
至于为什么update-alternatives --config python 修改没反应,期待各位大神帮忙解答~