您的位置:首页 > 博客中心 > 数据库 >

Mac OS X 下安装python的MySQLdb模块

时间:2022-03-10 18:20

  参考资料:

mac os x下python安装MySQLdb模块   http://www.codeif.com/post/1073/

MAC OSX使用Python安装模块有关问题  http://www.myexception.cn/operating-system/1616547.html

  在Mac OS X 中安装好了MySQL和Django,在Django中访问MySQL数据库时,提示“ImportError: No module named MySQLdb”,是由于没有安装Python连接MySQL所需的MySQLdb库。为了解决一系列的问题,查阅资料,花费了两个多小时才搞定。。。。。。

  在网址 http://sourceforge.net/projects/mysql-python/ 下载MySQLdb。

  直接双击解压,命令行进入解压后的目录,执行python setup.py build,出现“EnvironmentError: mysql_config not found”报错

gxlsystem.com,布布扣

  根据提示,需要编辑下mysql的路径,先找到本机的mysql的路径

gxlsystem.com,布布扣

  使用vim打开MySQL-Python安装文件中的setup_posix.py,找到“mysql_config.path = "mysql_config"”改为

gxlsystem.com,布布扣

  执行gxlsystem.com,布布扣

  发生报错“error: command ‘cc‘ failed with exit status 1”

gxlsystem.com,布布扣

  使用ARCHFLAGS将该error降级为warning

gxlsystem.com,布布扣

  安装成功MySQL-Python

gxlsystem.com,布布扣

   导入MySQLdb模块时,又有报错:

gxlsystem.com,布布扣

  需要添加软链接:

gxlsystem.com,布布扣

  最终可以正常使用。

Mac OS X 下安装python的MySQLdb模块,布布扣,bubuko.com

热门排行

今日推荐

热门手游