[英]Default python /usr/bin/python instead of /usr/local/bin/python
I have both python2.6 and python2.7 installed in my CentOS box. 我的CentOS盒子里安装了python2.6和python2.7。 python2.6 is installed at /usr/bin/python
and i have installed python2.7 from source at location /usr/local/bin/python
python2.6安装在/usr/bin/python
,我已经从源位置/usr/local/bin/python
安装了python2.7
after the installation my default python is changed to python2.7 instead of pythn2.6 at /usr/bin
, I want to use python 2.6 at /usr/bin/python
. 在安装之后我的默认python在/usr/bin
下改为python2.7而不是pythn2.6,我想在/usr/bin/python
使用python 2.6。 I have tried following things already nothing worked. 我已经尝试过以下已经无效的事情。
/usr/bin
我创建了符号链接,并指向/usr/bin
python 2.6 Please let me know how can i have python 2.7 installed along with 2.6 installed and python 2.6 as my default version. 请让我知道我如何安装python 2.7以及2.6安装和python 2.6作为我的默认版本。 I have the same thing working with my arch linux box, but this doesn't work with my centos box. 我和我的arch linux盒子一样工作,但这不适用于我的centos盒子。
Attaching my .bash_profile, 附上我的.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"
You could use alias to point the command python at the 2.6 folder, and python27 to point at 2.7 like so: 您可以使用别名将命令python指向2.6文件夹,将python27指向2.7,如下所示:
In .bash_profile add: 在.bash_profile中添加:
alias python=/usr/bin/python/<python executable name>
Thanks to @brett-beatty i have referred /usr/local/bin/python
symlink to /usr/bin
. 感谢@ brett-beatty,我已将/usr/local/bin/python
符号链接引用到/usr/bin
。 The compiler looks into /usr/local/bin
goes to /usr/bin
and uses the correct version also keeps it consistent. 编译器查看/usr/local/bin
转到/usr/bin
并使用正确的版本也保持一致。
softwarecollections.org is a default way to add a second version of a language, db, etc. You can then set the default. softwarecollections.org是添加语言,db等第二版的默认方法。然后,您可以设置默认值。 It's for RHEL 6/7 and CentOS 6/7. 它适用于RHEL 6/7和CentOS 6/7。
See https://www.softwarecollections.org/en/about/ 请参阅https://www.softwarecollections.org/en/about/
See https://www.softwarecollections.org/en/scls/?search=python 请参阅https://www.softwarecollections.org/en/scls/?search=python
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.