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 ...
随机推荐
- drag-html
<!doctype html><html><head><meta charset="UTF-8" /><title>Ca ...
- git 怎样删除远程仓库的最近一次错误提交?
假设你有3个commit如下: commit 3 commit 2 commit 1 其中最后一次提交commit 3是错误的,那么可以执行: git reset --hard HEAD~1 你会发现 ...
- 彻底搞懂oracle的标量子查询
oracle标量子查询和自己定义函数有时用起来比較方便,并且开发者也常常使用.数据量小还无所谓.数据量大,往往存在性能问题. 下面測试帮助大家彻底搞懂标量子查询. SQL> create tab ...
- Ubuntu 安装 spark
环境: Unbunt 12.04 Hadoop 2.2.x Sprak 0.9 Scala scala-2.9.0.final.tgz 步骤 1. 下载 scala 2. 解压scala,然后改动/e ...
- Unix系统介绍
一.基础知识 操作系统 用户与计算机硬件之间的界面,是控制.管理计算机内各种硬件与软件资源.它是一个多用户.多任务.分时的操作系统. 对于分时系统:假如a进程需要16个时间片,现在根据优先级只分配了1 ...
- python(2)- python程序的编写简单介绍
一.语句和语法 # 注释 \ 转译回车,继续上一行,在一行语句较长的情况下可以使用其来切分成多行,因其可读性差所以不建议使用 : 将两个语句连接到一行,可读性差,不建议使用 : 将代码的头和体分开 语 ...
- JS 省市两级联动(不带地区版本)
基于网上找的一个版本改造,因为项目需求不需要地区只要省.市,所以做了改版,两个input上直接取出了数据 <html> <head> <script src=" ...
- 关于 angular cookie 设置的坑
初识Angular,才知道掉进了这么一个各种大坑的坑. 先说下对于$cookie.put 这几个方法,只有1.4以上版本才可以用,其余低于版本请使用 $cookieStore: 下面举例下使用方法: ...
- SqlServer,Oracle,Mysql 获取指定行数
--sqlserver * FROM dbo.T_TASK --oracle --mysql ,
- 微信小程序 如何使用globalData
微信小程序在JavaScript文件中声明的变量和函数只在该文件中有效:不同的文件中可以声明相同名字的变量和函数,不会互相影响.如果希望在各个页面之间共同使用某些信息,并且可以对共享数据进行修改设置, ...