参考:http://blog.csdn.net/huanle0610/article/details/41174943
https://segmentfault.com/a/1190000007345825
1.
解决:进入目录 cd /root/Python-2.7.3/Modules/_ctypes/libffi 添加权限chmod +x ./configure
2.Error_Info 1: INFO: Can't locate Tcl/Tk libs and/or headers
解决:yum install -y tcl-devel tk-devel
参考:
You may have to install Tcl and Tk(when using RPM, install the –devel RPM as well) and /or edit the setup.py script to point to the right locations where Tcl/Tk is installed. If you install Tcl/Tk in the default locations, simply rerunning “make” should build the _tkinter extension.
3.Error_Info 2: Python build finished, but the necessary bits to build these modules were not found
无论报错信息如何,意思很明确,我们编译的时候,系统没有办法找到对应的模块信息,为了解决这些报错,我们就需要提前安装依赖包,这些依赖包对应列表如下(不一定完全):
模块 | 依赖 | 说明 |
_bsddb | bsddb | Interface to Berkeley DB library。Berkeley数据库的接口 |
_curses | ncurses | Terminal handling for character-cell displays。 |
_curses_panel | ncurses | A panel stack extension for curses。 |
_sqlite3 | sqlite | DB-API 2.0 interface for SQLite databases。SqlLite,CentOS可以安装sqlite-devel |
_ssl | openssl-devel.i686 | TLS/SSL wrapper for socket objects。 |
_tkinter | N/A | a thin object-oriented layer on top of Tcl/Tk。如果不使用桌面程序可以忽略TKinter |
bsddb185 | old bsddb module | 老的bsddb模块,可忽略。 |
bz2 | bzip2-devel.i686 | Compression compatible with bzip2。bzip2-devel |
dbm | bsddb | Simple “database” interface。 |
dl | N/A | Call C functions in shared objects.Python2.6开始,已经弃用。 |
gdbm | gdbm-devel.i686 | GNU’s reinterpretation of dbm |
imageop | N/A | Manipulate raw image data。已经弃用。 |
readline | readline-devel | GNU readline interface |
sunaudiodev | N/A | Access to Sun audio hardware。这个是针对Sun平台的,CentOS下可以忽略 |
zlib | Zlib | Compression compatible with gzip |
在CentOS下,可以安装这些依赖包:readline-devel,sqlite-devel,bzip2-devel.i686,openssl-devel.i686,gdbm-devel.i686,libdbi-devel.i686,ncurses-libs,zlib-devel.i686。完成这些安装之后,可以再次编译,上表中指定为弃用或者忽略的模块错误可以忽略。
解决:yum install -y readline-devel sqlite-devel bzip2-devel.i686 openssl-devel.i686 gdbm-devel.i686 libdbi-devel.i686 ncurses-libs,zlib-devel.i686
4.多版本共存解决:安装完python2.7之后,还是显示旧版(2.6)
mv /usr/bin/python /usr/bin/python2.6.6 执行一次就可以了,用于备份
ln -s /usr/local/bin/python2.7 /usr/bin/python 创建软连接
5.yum错误:解决因python版本变化,引起的yum问题
vi /usr/bin/yum 编辑文件
a 进入修改模式
#!/usr/bin/python2.6 修改第一行为原来Python路径
ESC 退出编辑模式
:wq 保存并退出