Centos 5.x 升级 python2.7,安装setuptools、mysqldb 完整记录
最近由于有个工作任务需要搭个虚拟机环境,但是环境是搭建在内网,无法直接联网,很多软件都不能直接yum安装,
安装过程实在十分不顺利,在此留个记录给有需要的朋友。
环境是 CentOS 5.7 x64
请选择合适的方式,下载python2.7.3安装包
http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
- yum install gcc
yum install gcc
- yum install zlib zlib-dev
yum install zlib zlib-dev
- tar jxvf Python-2.7.3.tar.bz2
- cd Python-2.7.3
- ./configure
- make && make instal
tar jxvf Python-2.7.3.tar.bz2
cd Python-2.7.3
./configure
make && make instal
- Traceback (most recent call last):
- File "<string>", line 1, in <module>
- zipimport.ZipImportError: can't decompress data; zlib not available
Traceback (most recent call last):
File "<string>", line 1, in <module>
zipimport.ZipImportError: can't decompress data; zlib not available
- #zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
#zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
- make & make install
make & make install
- rm -f /usr/bin/python
rm -f /usr/bin/python
把python执行软连接连接到2.7
- ln -s /usr/local/bin/python2.7 /usr/bin/python
ln -s /usr/local/bin/python2.7 /usr/bin/python
编辑yum命令,把路径指明为2.4,因为yum必须基于2.4版本
- sed -ie 's#/usr/bin/python$#/usr/bin/python2.4#g' /usr/bin/yum
sed -ie 's#/usr/bin/python$#/usr/bin/python2.4#g' /usr/bin/yum
- sh setuptools-0.6c11-py2.7.egg
sh setuptools-0.6c11-py2.7.egg
- Processing setuptools-0.6c11-py2.7.egg
- Copying setuptools-0.6c11-py2.7.egg to /usr/local/lib/python2.7/site-packages
- Adding setuptools 0.6c11 to easy-install.pth file
- Installing easy_install script to /usr/local/bin
- Installing easy_install-2.7 script to /usr/local/bin
- Installed /usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg
- Processing dependencies for setuptools==0.6c11
- Finished processing dependencies for setuptools==0.6c11
Processing setuptools-0.6c11-py2.7.egg
Copying setuptools-0.6c11-py2.7.egg to /usr/local/lib/python2.7/site-packages
Adding setuptools 0.6c11 to easy-install.pth file
Installing easy_install script to /usr/local/bin
Installing easy_install-2.7 script to /usr/local/bin Installed /usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg
Processing dependencies for setuptools==0.6c11
Finished processing dependencies for setuptools==0.6c11
- yum install MySQL-devel MySQL-client MySQL-shared-compat MySQL-shared
yum install MySQL-devel MySQL-client MySQL-shared-compat MySQL-shared
下载好mysqldb
- tar xvzf MySQL-python-1.2.3.tar.gz
- cd MySQL-python-1.2.3
- vim site.cfg
- 把上面的mysql_config路径注释删除以及改成实际路径,如果不知道mysql_config在哪里,运行命令:whereis mysql_config
- python setup.py install
tar xvzf MySQL-python-1.2.3.tar.gz
cd MySQL-python-1.2.3
vim site.cfg
把上面的mysql_config路径注释删除以及改成实际路径,如果不知道mysql_config在哪里,运行命令:whereis mysql_config
python setup.py install
- running build
- running build_py
- copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb
- running build_ext
- building '_mysql' extension
- gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/include/mysql -I/usr/local/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -g -pipe -m64 -fPIC -g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing -DMY_PTHREAD_FASTMUTEX=1
- 在包含自 _mysql.c:36 的文件中:
- /usr/include/mysql/my_config.h:422:1: 警告:“HAVE_WCSCOLL”重定义
- 在包含自 /usr/local/include/python2.7/Python.h:8 的文件中,
- 从 pymemcompat.h:10,
- 从 _mysql.c:29:
- /usr/local/include/python2.7/pyconfig.h:890:1: 警告:这是先前定义的位置
- gcc -pthread -shared build/temp.linux-x86_64-2.7/_mysql.o -L/usr/lib64 -lmysqlclient -lpthread -lm -lrt -ldl -o build/lib.linux-x86_64-2.7/_mysql.so
- /usr/bin/ld: cannot find -lmysqlclient
- collect2: ld 返回 1
running build
running build_py
copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb
running build_ext
building '_mysql' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/include/mysql -I/usr/local/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -g -pipe -m64 -fPIC -g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing -DMY_PTHREAD_FASTMUTEX=1
在包含自 _mysql.c:36 的文件中:
/usr/include/mysql/my_config.h:422:1: 警告:“HAVE_WCSCOLL”重定义
在包含自 /usr/local/include/python2.7/Python.h:8 的文件中,
从 pymemcompat.h:10,
从 _mysql.c:29:
/usr/local/include/python2.7/pyconfig.h:890:1: 警告:这是先前定义的位置
gcc -pthread -shared build/temp.linux-x86_64-2.7/_mysql.o -L/usr/lib64 -lmysqlclient -lpthread -lm -lrt -ldl -o build/lib.linux-x86_64-2.7/_mysql.so
/usr/bin/ld: cannot find -lmysqlclient
collect2: ld 返回 1
- find / -name 'libmysqlclient.so.*'
- /usr/lib64/libmysqlclient.so.14
- /usr/lib64/libmysqlclient.so.12
- /usr/lib64/libmysqlclient.so.14.0.0
- /usr/lib64/libmysqlclient.so.12.0.0
- /usr/lib64/libmysqlclient.so.16
- /usr/lib64/libmysqlclient.so.15
- /usr/lib64/libmysqlclient.so.15.0.0
- /usr/lib64/libmysqlclient.so.16.0.0
find / -name 'libmysqlclient.so.*'
/usr/lib64/libmysqlclient.so.14
/usr/lib64/libmysqlclient.so.12
/usr/lib64/libmysqlclient.so.14.0.0
/usr/lib64/libmysqlclient.so.12.0.0
/usr/lib64/libmysqlclient.so.16
/usr/lib64/libmysqlclient.so.15
/usr/lib64/libmysqlclient.so.15.0.0
/usr/lib64/libmysqlclient.so.16.0.0
- ln -s /usr/lib64/libmysqlclient.so.16.0.0 /usr/lib/libmysqlclient.so
ln -s /usr/lib64/libmysqlclient.so.16.0.0 /usr/lib/libmysqlclient.so
- python setup.py install
python setup.py install
- python
python
再import MySQLdb,注意大小写呢
- Python 2.7.3 (default, Dec 10 2012, 14:33:49)
- [GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2
- Type "help", "copyright", "credits" or "license" for more information.
- >>> import MySQLdb
- /usr/local/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-linux-x86_64.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /usr/local/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-linux-x86_64.egg/_mysql.pyc, but /home/soft/MySQL-python-1.2.3 is being added to sys.path
Python 2.7.3 (default, Dec 10 2012, 14:33:49)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
/usr/local/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-linux-x86_64.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /usr/local/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-linux-x86_64.egg/_mysql.pyc, but /home/soft/MySQL-python-1.2.3 is being added to sys.path
Centos 5.x 升级 python2.7,安装setuptools、mysqldb 完整记录的更多相关文章
- python基础之centos6.5 升级 python2.7, 安装pip, MySQLdb
这个仅仅是为了运行脚本需求, 将centos6.5中的 python 2.6.6升级到了 2.7 并且安装和了 pip 和 MySQLdb 1.先装依赖 yum install zlib-devel ...
- CentOS 6.5升级Python和安装IPython
<转自:http://www.noanylove.com/2014/10/centos-6-5-sheng-ji-python-he-an-zhuang-ipython/>自己常用.以做备 ...
- Centos/Linux 下升级python2.7至3.5.0
(一) 安装Python3.5 (1)在安装python之前,因为linux系统下默认没有安装wget,gcc,首先安装wget,gcc: [root@node6 python_scripts]# y ...
- CentOS 6.5升级Python和安装IPython(亲测可用)
python的升级(2.6------>2.7.x) 如下地址:http://note.youdao.com/share/?id=2928aeda020123bfdf2a2c76bc75e4a7 ...
- CentOS 6.5升级Python2.7
1.下载并解压Python2.7的源码. . 2.编译与安装Python2.7. ./configure --prefix=/usr/local make && make altins ...
- CentOS 7 下使用虚拟环境Virtualenv安装Tensorflow cpu版记录
1.首先安装pip-install 在使用centos7的软件包管理程序yum安装python-pip的时候会报一下错误: No package python-pip available. Error ...
- Centos下堡垒机Jumpserver V3.0环境部署完整记录(1)-安装篇
由于来源身份不明.越权操作.密码泄露.数据被窃.违规操作等因素都可能会使运营的业务系统面临严重威胁,一旦发生事故,如果不能快速定位事故原因,运维人员往往就会背黑锅.几种常见的运维人员背黑锅场景:1)由 ...
- Centos下堡垒机Jumpserver V3.0环境部署完整记录(2)-配置篇
前面已经介绍了Jumpserver V3.0的安装,基于这篇安装文档,下面说下Jumpserver安装后的的功能使用: 一.jumpserver的启动 Jumpserver的启动和重启 [root@t ...
- yum 方式安装mysql (完整记录)
2016-04-07 学习笔记,源代码安装比较麻烦,还是要尝试一下yum安装和rpm方式安装 一.检查系统是否安装老版本,有的话干掉 #yum list installed | grep mysqlm ...
随机推荐
- 【bootstrap】bootstrap中的tooltip的使用
先看看效果图:[当光标放在下面这个时间搜索框上时,显示一段文字:搜索时间段中的流水信息] 这样的效果,怎么实现呢? 很简单 1.引入jQuery.js和bootstrap的js和css 2.给想要有t ...
- jquery中美元符号($)命名冲突
http://blog.csdn.net/shanshan209/article/details/6341727 在Jquery中,$是JQuery的别名,所有使用$的地方也都可以使用JQuery来替 ...
- Go语言阅读小笔记,来自知呼达达关于unsafe.Pointer的分享.
第一式 - 获得Slice和String的内存数据 func stringPointer(s string) unsafe.Pointer { p := (*reflect.StringHeader) ...
- x264 编码数配置
记录项目中用到一组x264快速编码参数配置,具体如下: param->i_frame_reference = 1; param->i_scenecut_threshold = 0; par ...
- 【学习笔记】C#中HashTable和快速排序的用法,从单词频率统计小程序写起
先瞎扯点别的.进入这个神圣的地方总需要些鞭策,阿西巴,我是被鞭策进来摆摊的程序猿.软件工程老师说,写程序,发博客,就来博客园.这是个号召力很强的口号.最近看网络营销 搜索引擎优化的书多一些,只能说王老 ...
- linux之return和exit引发的大问题(vfork和fork)
在coolshell.cn上看到的一个问题.为此拿来研究一下. 首先 看看return和exit的差别 在linux上分别跑一下这个代码 int main() { return 0; //exit(0 ...
- Android调用JNI本地方法跟踪目标代码
正如Android调用JNI本地方法经过有点改变章所说跟踪代码是可行的,但是跟踪某些代码会出现anr,点击取消,还是不好运,有提高办法吗?回答是有(gdb还没试过,本文只讨论ida). 下面是我使用 ...
- MySQL安装过程中出现“APPLY security settings错误”的解决方式
***********************************************声明*************************************************** ...
- 在html文件引入其它html文件的几种方法
1.IFrame引入,看看下面的代码 <IFRAME NAME="content_frame" width=100% height=600 marginwidth=0 mar ...
- SAP-ABAP系列 第二篇SAP ABAP开发基础
第二章SAP ABAP开发基础 1.ABAP数据类型及定义 ABAP程序中共包含8种基本数据类型定义, 类型名称 描述 属性 C Character Text (字符类型) 默认长度=1,默认值 = ...