python-linux设置python环境变量
linux设置python环境变量--参考linux安装jdk环境变量
添加环境变量主要是在/etc/profile中
例如,在/usr/local/下安装了python2.7
因为系统默认是2.4,所以
#python
Python 2.4.3 (#1, Sep 3 2009, 15:37:37)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
进⼊python2.7的安装路径,在/bin下到python⽂件
.
/python
Python 2.7.2 (default, Feb 2 2012, 11:45:14)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
先查看下⽬前的环境变量
#echo $PATH
/usr/local/jdk1.5/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
默认是没有最新的python2.7的
我进⼊新装的python2.7⽬录查看
/usr/local/python/bin/python2.7
这个就是python2.7的启动⽂件
# PATH=$PATH:/usr/local/python/bin/
# echo $PATH
/usr/local/jdk1.5/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/python/bin/将新装的/usr/local/python/bin添加到环境变量中
这时当我们输⼊
# python2.7
Python 2.7.2 (default, Feb 2 2012, 11:45:14)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
因为系统会⾃动在环境中寻python2.7这个⽂件并启动,但会优先/usr/bin下的启动⽂件,所以
当#python时,还是会进⼊2.4的默认系统
进⼊/usr/bin,将python删除,建⽴连接
ln -s /usr/local/python/bin/python ./python
这样我们#python 的时候,就会直接进⼊2.7的环境了
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论