1. 下载python源码包
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
2. 解压
tar -xjf Python-2.7.3.tar.bz2
3. 创建新python目录
mkdir /usr/local/python2.7
4. 编译安装
tar xf Python-2.7.3.tgz
cd Python-2.7.3
./configure --prefix=/usr/local/python2.7
make && make install
5. 此时还没有覆盖老版本,可以先将旧python版本改成别的名字
mv /usr/bin/python /usr/bin/python_old
6. 为新版本的python建立like
ln -s 1116.www.qixoo.qixoo.com/usr/local/python2.7/bin/python2.7 /usr/bin/python
7. 测试,在命令行输入python,就会显示当前python的版本信息
[ ~]# python
Python 2.7.3 (default, Nov 15 2016, 16:58:04)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
时间: 2024-12-05 09:57:53