Python的MySQLdb模块安装
2014-04-25 11:32
387 查看
Python的MySQLdb模块安装
在配置Django时,选择的是mysql数据库,要安装MySQLdb模块,不过安装过程中,遇到了很多errors,记录一下。系统:ubuntu 11.10
mysql:直接apt-get安装的,version:5.1.62
到官方下载MySQL for Python
然后解压,打开README:
里面有安装过程:
tarxfzMySQL−python−1.2.1.tar.gz cd
MySQL-python-1.2.1
# edit site.cfg if necessary
python setup.py build
$ sudo python setup.py install # or su first
不过在python setup.py build时报错:
ImportError: No module named setuptools
ubuntu下安装:
sudo apt-get install python-setuptools
python-setuptools : Python Distutils Enhancements (setuptools compatibility)
然后再次python setup.py build,又报错:
EnvironmentError: mysql_config not found
因为mysql_config是属于MySQL开发用的文件,而使用apt-get安装的MySQL是没有这个文件的,于是在包安装器里面寻找
sudo apt-get install libmysqld-dev
libmysqld-dev : MySQL embedded database development files
再次运行python setup.py build,报错:
building ‘_mysql’ extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,3,’final’,0) -D__version__=1.2.3 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-i686-2.7/_mysql.o -DBIG_JOINS=1 -fno-strict-aliasing
-DUNIV_LINUX -DUNIV_LINUX
In file included from _mysql.c:29:0:
pymemcompat.h:10:20: fatal error: Python.h: No such file or directory
解决方案,
sudo apt-get install python-dev
python-dev : header files and a static library for Python (default)
然后就按照README里的:
pythonsetup.pybuild sudo
python setup.py install
测试:
>>>import MySQLdb
没有报错即可。
相关文章推荐
- wins下python安装MySQLdb模块
- Python安装MySQLDb模块的问题及解决方法
- Centos 安装python MySQL 模块 -- MySQLdb
- Python 安装 MySQLdb 模块
- centos7安装python的MySQLdb模块
- python 第三方模块MySQLdb安装
- Python的MySQLdb模块安装
- win7下安装python-mysqldb模块以及还报No module named MYSQLdb错误的原因
- Python安装MySQLDb模块的种种问题及解决
- Linux下安装 MySQLdb模块 MySQL-python 坎坷之路
- Python安装MySQLdb模块(Linux)
- Python安装 python-mysqldb模块方法
- mac os x 安装 python MySQLdb 模块 记录
- Python的MySQLdb模块安装
- windows环境下安装python的mysqldb模块
- 在Python安装MySQLdb模块遇见的问题
- python操作三大主流数据库(1)python操作mysql①windows环境中安装python操作mysql数据库的MySQLdb模块mysql-client
- Python的MySQLdb模块安装
- Python中MySQLdb模块的安装
- python安装MySQLDb模块