码迷,mamicode.com
首页 > 数据库 > 详细

Python的MySQLdb模块安装

时间:2016-03-12 21:30:38      阅读:241      评论:0      收藏:0      [点我收藏+]

标签:

首先,请安装mysql

sudo apt-get install mysql

期间,需要设置root 密码


下载mysql-python: http://sourceforge.net/projects/mysql-python/?source=dlp

解压: tar  zxvf  MySQL-python-1.2.4b4.tar.gz

进到该目录: cd MySQL-python-1.2.4b4

执行安装脚本:  python setup.py build 

                              python setup.py install  


这个时候就会出现问题了:

sh: mysql_config: command not found
Traceback (most recent call last):
  File "setup.py", line 15, in <module>
    metadata, options = get_config()
  File "/usr/lib/python2.5/MySQL-python-1.2.3/setup_posix.py", line 43, in get_config
    libs = mysql_config("libs_r")
  File "/usr/lib/python2.5/MySQL-python-1.2.3/setup_posix.py", line 24, in mysql_config
    raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found

根据提示可知,mysql_config 找不到!!!!

网友解决思路如下:

vi site.cfg 
把 mysql_config = /usr/local/mysql/bin/mysql_config 这一行前的#去掉,并且把mysql_config的路径设置正确。 
python setup.py build 
sudo python setup.py install 

但是我的系统中根本就找不到mysql_config 文件,原因是该文件是通过安装另外一个包才能安装到系统中的

另一位牛人回复到:

mysql-config is in a different package, which can be installed from (again, assuming debian / ubuntu):

sudo apt-get install libmysqlclient-dev

好了,终于找到原因了,于是安装包libmysqlclient-dev

然后查看mysql_config 文件的安装目录是/usr/bin/mysql_config 

 

Python的MySQLdb模块安装

标签:

原文地址:http://www.cnblogs.com/fengjian2016/p/5269991.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!