linux 下 mysql-python 安装

来源:互联网 发布:php木马图片制作 编辑:程序博客网 时间:2024/05/16 11:58

root权限

1.安装yum install mysql-devel.x86_64

这个包包含了开发时必备的一些文件


2、首先从sourceforge下载安装:

1
2
cd/usr/local/src/
wget http://nchc.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.4b4.tar.gz

3、解压缩文件:

1
2
tarxzvf MySQL-python-1.2.4b4.tar.gz
cdMySQL-python-1.2.4b4


4.build和install

1
2
python setup.py build
python setup.pyinstall


5.测试

Python 2.7.6 (default, Apr 15 2014, 12:16:45)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb;
>>>


安装过程遇到问题,不过实际遇到一些问题:

问题1:ImportError: No module named setuptools
好吧,需要安装setuptools
官网页面:https://pypi.python.org/pypi/setuptools#installation-instructions

> wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py> python ez_setup.py --user

问题2:error: command 'gcc' failed with exit status 1
额。。。 新装的系统,啥都没装呢。。。
# yum -y install gcc


问题3:error: Python.h: No such file or directory
系统中没有Python.h的原因,是因为没有安装python的开发版,即Python-devel这个包,命令提示符下执行
yum install python-devel


问题4:/usr/bin/ld: cannot find -lz,造成编译错误
yum install zlib-devel








0 0
原创粉丝点击