簡體   English   中英

幫助在Mac OS X下為Python安裝MySQLdb

[英]Help installing MySQLdb for Python under Mac OS X

我知道這個問題已經被問過幾次了,但是經過幾個小時的嘗試,仍然沒有辦法使它起作用。

我已經從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

......

非常感謝您能提供的任何幫助。 謝謝!

嘗試macports

$ port search python | grep mysql
py-mysql @1.2.2 (python, devel, databases)
Python interface to mysql
py25-mysql @1.2.2 (python, devel, databases)
Python interface to mysql
py26-mysql @1.2.3 (python, devel, databases)
py27-mysql @1.2.2 (python, devel, databases)
Python interface to mysql

對於32位和64位Mac Snow Leopard安裝(在兩台不同的計算機上),我的回答對我有用在Mac OS X 10.6 Snow Leopard上使用MAMP安裝適用於Django的MySQLdb

簡潔版本:

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

如果您不想在Mac上處理軟件包管理器的煩惱,請在此安裝指南中詳細介紹我的經驗: http : //alexandersimoes.com/journal/2011/03/04/install-mysqldb-在Mac OSX上的雪豹/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM