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 ...
随机推荐
- iOS -- SKEmitterNode类
SKEmitterNode类 继承自 SKNode:UIResponder:NSObject 符合 NSCoding(SKNode)NSCopying(SKNode)NSObject(NSObje ...
- Golang协程与通道整理
协程goroutine 不由OS调度,而是用户层自行释放CPU,从而在执行体之间切换.Go在底层进行协助实现 涉及系统调用的地方由Go标准库协助释放CPU 总之,不通 ...
- Android--绑定服务调用服务的方法
Service依照其启动的方式,可分为两种: 1.Started Started的Service.通过在Application里用startService(Intent intent)方法来启动.这样 ...
- HDU 2648(搜索题,哈希表)
#include<iostream> #include<map> #include<string> #include<cstring> #include ...
- Anyoffice -HTML5大赛 悦心(基于H5开发安卓音乐app)-项目总结
项目在线演示地址:http://rose111.applinzi.com/ github 地址:欢迎star https://github.com/midoxinxin/YueX-Music 悦心,一 ...
- 随便写一点最近开发遇到的问题和解决方法 大部分关于laravel和php
laravel里要想对对象进行自己设计的排序(usort()), 得用匿名方法, 原声php就不用 php里面可以随便写html代码, 比如可以把html直接后缀名改成.php, 然后在任何地方& ...
- OI知识体系
- canvas 星空插件
(function(a){ a.fn.starBg=function(p){ var p=p||{}; var w_w=p&&p.window_width?p.window_width ...
- JS 模板引擎 Handlebars.js 中文说明
Handlebars 为你提供了一个可以毫无挫折感的高效率书写 语义化的模板 所必需的一切. Mustache 模板和 Handlebars 是兼容的,所以你可以把Mustache模板拿来导入到Han ...
- Spring的常见问题及答案
目录 Spring 概述 依赖注入 Spring beans Spring注解 Spring数据访问 Spring面向切面编程(AOP) Spring MVC Spring 概述 1. 什么是spri ...