添加环境变量主要是在/etc/profile中 例如,在/usr/local/下安装了python2.7 因为系统默认是2.4,所以 #python Python 2.4.3 (#1, Sep [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的环境了 |
|