一开始有这个需求,是因为用 YaH3C 替代 iNode 进行校园网认证时,一直编译错误,提示找不到
Python 的某个模块,百度了一下,此模块是在 Python2.7 以上才有的,但是系统的自带的Python是2.6版本,难怪一直连不上网。于是,继续百度google,进行安装,后来又出现问题...在此开篇记录一下,权当备忘。
1.下载Python-2.7.3
2.解压
3.更改工作目录
4.安装
configure错误
果断安装make搞定
5.查看版本信息
6.建立软连接,使系统默认的 python指向 python2.7
7.重新检验Python 版本
8解决系统 Python 软链接指向 Python2.7 版本后,因为yum是不兼容 Python 2.7的,所以yum不能正常工作,我们需要指定 yum 的Python版本
#!/usr/bin/python
查看python的版本
- #python -V
- Python 2.6.6
1.下载Python-2.7.3
- #wget http://python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
2.解压
- #tar -jxvf Python-2.7.3.tar.bz2
3.更改工作目录
- #cd Python-2.7.3
4.安装
- #./configure
- #make all
- #make install
- #make clean
- #make distclean
configure错误
碰到已下错误,很明显没GCC工具不在环境变量PATH里面,可以看出云服务器默认没有安装
- [root@Sven Python-3.3.2]# ./configure --prefix=/usr/local/python33
- checking build system type... x86_64-unknown-linux-gnu
- checking host system type... x86_64-unknown-linux-gnu
- checking for --enable-universalsdk... no
- checking for --with-universal-archs... 32-bit
- checking MACHDEP... linux
- checking for --without-gcc... no
- checking for gcc... no
- checking for cc... no
- checking for cl.exe... no
- configure: error: in `/usr/local/src/Python-3.3.2':
- <span style="color:#FF0000;">configure: error: no acceptable C compiler found in $PATH</span>
- See `config.log' for more details
解决方案
yum安装gcc,
- yum install gcc -y
make错误
当我准备make 的时候发现这个也没有,囧
- [root@Sven Python-3.3.2]# make
- -bash: make: command not found
果断安装make搞定
- yum install make -y
然后就没有然后了,安装好了,把新安装的执行程序软链到环境变量就可以用了:
- ln -s /usr/local/python33/bin/python3 /usr/bin/python3
5.查看版本信息
- #/usr/local/bin/python2.7 -V
6.建立软连接,使系统默认的 python指向 python2.7
- #mv /usr/bin/python /usr/bin/python2.6.6
- #ln -s /usr/local/bin/python2.7 /usr/bin/python
7.重新检验Python 版本
- #python -V
8解决系统 Python 软链接指向 Python2.7 版本后,因为yum是不兼容 Python 2.7的,所以yum不能正常工作,我们需要指定 yum 的Python版本
- #vi /usr/bin/yum
#!/usr/bin/python
改成
#!/usr/bin/python2.6.6
http://www.zhangchun.org/the-centos6-3-upgrade-python-to-2-7-3-
这篇教程就到这里了,但是不久就突然发现输入法图标不见了,然后打字没有候选框!iBus 崩了!再次进行搜索,又是版本问题 iBus也是不支持Python2.7的啊!
于是。。。
9.配置iBus
分别用 vi 打开下面两个文件,找到 exec python 那一行,把exec python 改为 exec python2.6 保存,退出。iBus在重启后就恢复正常了!是不是很开心?
- #vi /usr/bin/ibus-setup
- #vi/usr/libexec/ibus-ui-gtk