标签:
python版本升级python安装it |
分类: python |
[root@localhost ~]# cd
/home/
[root@localhost home]# cd niuxl/Python-2.7.4
[root@localhost Python-2.7.4]# ls
config.guess
config.sub
编译之前,如果没有需要先安装zlib包:
[root@localhost Python-2.7.4]# ./configure
--prefix=/usr/local/python2.7.4
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for --enable-universalsdk... no
checking for --with-universal-archs... 32-bit
checking MACHDEP... linux2
checking EXTRAPLATDIR...
checking for --without-gcc... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/home/niuxl/Python-2.7.4':
configure: error: no acceptable C compiler found in
$PATH
缺少c编辑器
安装c编辑器
..略
继续编译python
[root@localhost Python-2.7.4]# ./configure --prefix=/usr/local/python2.7.4..(略)
ok编译成功
[root@localhost Python-2.7.4]# make && make install
安装成功
[root@localhost
Python-2.7.4]# python -V
Python 2.4.3
目前版本依然是2.4.3,现在开始升级python,
查看python命令所在目录
[root@localhost
Python-2.7.4]# whereis python
python: /usr/bin/python2.4 /usr/bin/python /usr/lib/python2.4
/usr/include/python2.4 /usr/share/man/man1/python.1.gz
将/usr/bin/python 的软连接修改为python2.4.3
[root@localhost Python-2.7.4]# mv /usr/bin/python /usr/bin/python2.4.3
[root@localhost
Python-2.7.4]# python
-bash: /usr/bin/python: 没有那个文件或目录
python命令找不到,这时只需要将版本python2.7.4命令加入环境变量即可!
方式1:
修改/etc/profile加入如下两行:
PATH=$PATH:/usr/local/python2.7.4/bin
export PATH
然后
[root@localhost Python-2.7.4]# source /etc/profile
[root@localhost
Python-2.7.4]# python -V
Python 2.7.4
当然也可以创建2.7.4版本的python的软连接:/usr/bin/python
[root@localhost ~]# ln -s /usr/local/python2.7.4/bin/python /usr/bin/python
亦可
ok,python升级完成