bin*_*.py 7 python linux centos rhel
我的 CentOS 机器中安装了 python2.6 和 python2.7。python2.6安装在/usr/bin/python,我已经从位置的源安装了python2.7/usr/local/bin/python
安装后我的默认 python 更改为 python2.7 而不是 pythn2.6 at /usr/bin,我想使用 python 2.6 at /usr/bin/python。我已经尝试过以下事情已经没有任何效果。
/usr/bin请让我知道如何安装 python 2.7 和 2.6,并将 python 2.6 作为我的默认版本。我的 arch linux 盒子也有同样的事情,但这不适用于我的 centos 盒子。
附上我的 .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"
Run Code Online (Sandbox Code Playgroud)
我有同样的问题。以下命令修复了它:
sudo ln -sf /usr/bin/python /usr/local/bin/python
Run Code Online (Sandbox Code Playgroud)
这将从/usr/local/bin/python--> 建立一个符号链接/usr/bin/python。从这里引用
您可以使用 alias 将命令 python 指向 2.6 文件夹,并使用 python27 指向 2.7 文件夹,如下所示:
在.bash_profile中添加:
alias python=/usr/bin/python/<python executable name>
Run Code Online (Sandbox Code Playgroud)