Python的MySQLdb模块安装
来源:互联网 发布:营销人员数据统计分析 编辑:程序博客网 时间:2024/05/22 16:26
http://www.cnblogs.com/rollenholt/archive/2012/05/07/2487137.html
系统:ubuntu 11.10
mysql:直接apt-get安装的,version:5.1.62
到官方下载MySQL for Python
然后解压,打开README:
里面有安装过程:
# edit site.cfg if necessary# 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里的:
测试:
>>>import MySQLdb
没有报错即可。
参考:
http://blog.csdn.net/guzicheng/article/details/5884106
http://be-evil.org/post-185.html
http://hi.baidu.com/hevensun/blog/item/3b6e313fe8515df154e7238f.html
http://stackoverflow.com/questions/1449130/how-to-install-mysqldb-package-importerror-no-module-named-setuptools
http://www.cnblogs.com/objdump/archive/2011/11/03/mysql_python_install_error.html
- Python的MYSQLdb模块安装
- Python的MySQLdb模块安装
- Python的MySQLdb模块安装
- Python的MySQLdb模块安装
- python 安装MySQLdb模块
- 安装MySQLdb模块-python
- MySQLdb python模块安装
- python安装mysqldb模块
- python 安装MySQLdb模块
- python安装mysqldb模块
- python 安装 MySQLdb模块
- Python 安装 MySQLdb 模块
- windows 下安装 python 的 mysqldb 模块
- Python安装MySQLDb模块的相关步骤
- easy_install安装python的MySQLdb模块
- Python中MySQLdb模块的安装
- Python 连接数据库MySQLdb模块的安装
- Python下的Mysql模块MySQLdb安装
- 前端学习之路css(04)-基础知识
- 十五天精通WCF——第七天 Close和Abort到底该怎么用才对得起观众
- 交叉编译e2fsprogs For android
- 十五天精通WCF——第八天 对“绑定”的最后一点理解
- 前端学习之路css(05)-基础知识
- Python的MySQLdb模块安装
- 十五天精通WCF——第九天 高级玩法之自定义Behavior
- 数据集总结
- JQuery 绑定select标签的onchange事件,弹出选择的值,并实现跳转、传参
- 十五天精通WCF——第十天 学会用SvcConfigEditor来简化配置
- 前端学习之路css(06)-基础知识
- 十五天精通WCF——第十一天 如何对wcf进行全程监控
- 前端学习之路css3(01)-基础知识
- 十五天精通WCF——第十二天 说说wcf中的那几种序列化