Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
帮助在Mac OS X下安装MySQLdb for Python_Python_Mysql_Macos_Mysql Python - Fatal编程技术网

帮助在Mac OS X下安装MySQLdb for Python

帮助在Mac OS X下安装MySQLdb for Python,python,mysql,macos,mysql-python,Python,Mysql,Macos,Mysql Python,我知道这已经被问了好几次了,但经过几个小时的尝试,没有办法让这项工作成功 我已经从dmg文件和MySQL-python-1.2.3安装了MySQL 32位 我遵循了,但当我运行python setup.py build时,出现了以下错误: running build running build_py copying MySQLdb/release.py -> build/lib.macosx-10.6-fat-2.6/MySQLdb running build_ext building '

我知道这已经被问了好几次了,但经过几个小时的尝试,没有办法让这项工作成功

我已经从dmg文件和MySQL-python-1.2.3安装了MySQL 32位

我遵循了,但当我运行
python setup.py build
时,出现了以下错误:

running build
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.6-fat-2.6/MySQLdb
running build_ext
building '_mysql' extension
gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -pipe -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/local/mysql-5.5.12-osx10.6-x86/include -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c _mysql.c -o build/temp.macosx-10.6-fat-2.6/_mysql.o -Os -g -fno-common -fno-strict-aliasing -arch i386
In file included from _mysql.c:36:
/usr/local/mysql-5.5.12-osx10.6-x86/include/my_config.h:326:1: warning: "SIZEOF_SIZE_T" redefined
In file included from /System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:9,
                 from pymemcompat.h:10,
                 from _mysql.c:29:
/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pymacconfig.h:39:1: warning: this is the location of the previous definition
In file included from _mysql.c:36:
/usr/local/mysql-5.5.12-osx10.6-x86/include/my_config.h:419:1: warning: "HAVE_WCSCOLL" redefined
In file included from /System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:8,
                 from pymemcompat.h:10,
                 from _mysql.c:29:
/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pyconfig.h:803:1: warning: this is the location of the previous definition
_mysql.c:76: error: expected specifier-qualifier-list before ‘MYSQL’
_mysql.c:90: error: expected specifier-qualifier-list before ‘MYSQL_RES’
_mysql.c: In function ‘_mysql_Exception’:
_mysql.c:120: warning: implicit declaration of function ‘mysql_errno’
_mysql.c:120: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
_mysql.c:132: error: ‘ER_DB_CREATE_EXISTS’ undeclared (first use in this function)
_mysql.c:132: error: (Each undeclared identifier is reported only once

如果你能提供帮助,我将不胜感激。谢谢

试试看:

尝试:


如果您不想在mac电脑上处理软件包管理器的头痛问题,我在本安装指南中详细介绍了我的经验:

如果您不想在mac电脑上处理软件包管理器的头痛问题,我在本安装指南中详细介绍了我的经验:

我在这里的回答适用于32位和64位Mac Snow Leopard安装(在两台不同的机器上):

简短版本:

[user]$ sudo su
[root]# ARCHFLAGS="-arch $(uname -m)" pip install mysql-python

我的答案适用于32位和64位Mac Snow Leopard安装(在两台不同的机器上):

简短版本:

[user]$ sudo su
[root]# ARCHFLAGS="-arch $(uname -m)" pip install mysql-python

嘿,谢谢!我不知道我刚才做了什么,但是:D如果我从Python CLI运行“import MySQLdb”,它不会找到它。如何检查它是否正确安装?该命令没有安装它<不过,code>sudo端口安装py-mysql(或者您想要的任何一个)都会这样做。和
端口列表| grep py mysql
将显示是否安装了它。是的,我现在就得到了它,我正在安装,看看它是如何运行的。谢谢,嘿,谢谢!我不知道我刚才做了什么,但是:D如果我从Python CLI运行“import MySQLdb”,它不会找到它。如何检查它是否正确安装?该命令没有安装它<不过,code>sudo端口安装py-mysql(或者您想要的任何一个)都会这样做。和
端口列表| grep py mysql
将显示是否安装了它。是的,我现在就得到了它,我正在安装,看看它是如何运行的。谢谢。看起来编译器找不到MySQL头文件。您安装的DMG是否包含头文件?如果是这样的话,您可以通过设置CFLAGS环境变量将编译器指向正确的方向。它包含几个pkg文件来安装它…可能的重复项看起来编译器找不到MySQL头文件。您安装的DMG是否包含头文件?如果是这样的话,您可以通过设置CFLAGS环境变量来为编译器指明正确的方向。它包含了一些pkg文件来安装它……可能的重复版本非常有用。谢谢,这很有帮助。非常感谢。