2012-01-11 183 views
3

我的MAMP已經安裝在我的mac中。 所以MAMP中的mysql運行得很好。 但是,當我嘗試安裝MySQLdb的,我得到以下錯誤在mac上安裝MySQLdb

Traceback (most recent call last): 
File "setup.py", line 15, in <module> 
metadata, options = get_config() 
File "/Users/mohitdeepsingh/Downloads/MySQL-python-1.2.3/setup_posix.py", line 43, in get_config 
    libs = mysql_config("libs_r") 
File "/Users/mohitdeepsingh/Downloads/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等 但isnt mysql已經在那裏。 我需要改變某種配置文件嗎?如果是這樣任何人都可以點它的配置文件,我應該修改

回答

5

你必須搞清楚,如果在毫安一個mysql_config二進制的,如果它的存在,然後做:

export PATH="path-to-the-dir-with-mysql-config:$PATH"

安裝MySQL-python的之前。

+0

嗨..我認爲MySQL的配置文件是在出口PATH =「/應用程序/ MAMP /庫/斌/ mysql_config:$ PATH」 但我仍然得到同樣的錯誤 – Fraz 2012-01-11 06:01:34

+2

你必須在最後沒有'mysql_config'命令'export PATH =「/ Applications/MAMP/Library/bin:$ PATH」''。 – 2012-01-11 06:40:21

1

在mac上構建MySQLdb需要MySQL的頭文件和動態庫,它們不包含在標準MAMP中。如果你堅持純粹使用MAMP,你可以read this guide

幸運的是,有一個更簡單的解決方案:安裝py27-mysql,然後使用mysql的頭和庫。下面是它的工作對我來說:

$ sudo port install py27-mysql 

$ sudo env "PATH=$PATH:/opt/local/lib/mysql5/bin" pip install mysql-python