2012-10-09 116 views
0

我想在python中導入MySQldb並從XAMPP中的php腳本中調用python腳本。下面是我做的:在Mac OSX 10.6.8上安裝MySQLdb for Python在XAMPP中使用mysql時出錯

環境: 1的Mac OSX 10.6.8 2. Python版本2.6(默認值)[64]

完成至今: 1.安裝XAMPP 2. MySQL的配置路徑:/應用/ XAMPP/xamppfiles/bin中/ mysql_config 3.下載的MySQL-蟒-1.2.4b4 4.編輯與配置路徑site.cfg爲MySQL 5.冉以下命令

須藤蟒設置。 py clean python setup.py build

得到了以下錯誤:

running build 
running build_py 
copying MySQLdb/release.py -> build/lib.macosx-10.6-universal-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,4,'beta',4) - D__version__=1.2.4b4 -I/Applications/XAMPP/xamppfiles/include/mysql - I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c _mysql.c -o build/temp.macosx-10.6-universal-2.6/_mysql.o -mmacosx-version-min=10.4 -arch i386 -arch ppc -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ - DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL 
In file included from _mysql.c:44: 
/Applications/XAMPP/xamppfiles/include/mysql/my_config.h:1053:1: warning: "HAVE_WCSCOLL" redefined 
In file included from /System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:8, 
      from _mysql.c:29: 

/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pyconfig.h:803:1:警告:這是先前定義的位置 /usr/libexec/gcc/powerpc-apple-darwin10/4.2.1/as:彙編程序(/usr/bin/../libexec/gcc/darwin/ppc/as或/ usr/bin/../local/libexec/gcc/darwin/ppc/as)用於架構ppc未安裝 已安裝的裝配器爲: /usr/bin/../libexec/gcc/darwin/x86_64/as架構x86_64 /usr/bin /../ libexec/gcc/darwin/i386 /至於架構i386 在文件包含在_mysql.c:44: /Applications/XAMPP/xamppfiles/include/mysql/my_config.h:1053:1:警告:「HAVE_WCSCOLL」重新定義 從/System/Library/Frameworks/Python.framework/包含的文件版本/ 2.6/include/python2.6/Python.h:8, from _mysql.c:29:/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pyconfig.h:803 :1:警告:這是以前定義的位置 _mysql.c:3131:致命錯誤:錯誤寫入 - :損壞的管道 編譯終止。 脂:無法打開輸入文件:/var/tmp//ccQsr7Lk.out(沒有這樣的文件或目錄) 錯誤:命令 'GCC-4.2' 失敗,退出狀態1

回答

0

百勝安裝mysql-devel的

pip install MySQL-python