我的 CentOS 盒子里同时安装了 python2.6 和 python2.7。 python2.6 安装在 /usr/bin/python
并且我已经从源代码安装了 python2.7 在位置 /usr/local/bin/python
安装后,我的默认 python 在 /usr/bin
更改为 python2.7 而不是 pythn2.6,我想在 /usr/bin/python
使用 python 2.6。我已经尝试过以下已经没有任何效果的事情。
- 我创建了符号链接并使其指向 python 2.6
/usr/bin
- 我已经在 .bash_profile 中修改了我的默认 python 路径,但这仍然不起作用
请让我知道如何安装 python 2.7 和 2.6,并将 python 2.6 作为我的默认版本。我的 arch linux box 也有同样的功能,但这不适用于我的 centos box。
附上我的 .bash_profile,
# .bash_profile
export _BASH_PROFILE=1
# Get the aliases and functions
if [ -z "$_BASHRC" ]; then
. ~/.bashrc
fi
unset _BASH_PROFILE
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
BASH_ENV=$HOME/.bashrc
USERNAME=""
export USERNAME BASH_ENV PATH
export user=$(/usr/bin/whoami)
export WK_PORT=8086
export WK_PATH=ADC
# For DEV accounts change PYDOC_PORT value to 7400 + webkit number. For
# example WK23 would be port number 7423
export PYDOC_PORT=7464
alias serve="python -m SimpleHTTPServer"
unset _BASH_PROFILE
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
BASH_ENV=$HOME/.bashrc
USERNAME=""
export USERNAME BASH_ENV PATH
export user=$(/usr/bin/whoami)
export WK_PORT=8086
export WK_PATH=ADC
# For DEV accounts change PYDOC_PORT value to 7400 + webkit number. For
# example WK23 would be port number 7423
export PYDOC_PORT=7464
alias serve="python -m SimpleHTTPServer"
PYTHONPATH="$PYTHONPATH:/usr/bin/python"
原文由 binu.py 发布,翻译遵循 CC BY-SA 4.0 许可协议
我有同样的问题。以下命令修复了它:
这将从
/usr/local/bin/python
–>/usr/bin/python
创建一个符号链接。从 这里 提到