2017-10-08 93 views
0

我在Mac 10.13上使用python 2.7 我已經在我的Mac上安裝了MySQL,但是當我想安裝MySQL-python時,不斷收到錯誤。嘗試在Mac上安裝MySQL-python,但保持錯誤

我想點子:

須藤PIP安裝mysql-python的

,但得到:

Collecting mysql-python 
    Downloading MySQL-python-1.2.5.zip (108kB) 
    100% |████████████████████████████████| 112kB 1.9MB/s 
    Complete output from command python setup.py egg_info: 
    Traceback (most recent call last): 
     File "<string>", line 1, in <module> 
     File "/private/tmp/pip-build-AhyoBa/mysql-python/setup.py", line 17, in <module> 
     metadata, options = get_config() 
     File "setup_posix.py", line 53, in get_config 
     libraries = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag("l")) ] 
     File "setup_posix.py", line 8, in dequote 
     if s[0] in "\"'" and s[0] == s[-1]: 
    IndexError: string index out of range 

---------------------------------------- 
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-AhyoBa/mysql-python/ 

然後我試圖將文件直接移動到 '站點包' ,並跑了:

python /Users/dandizhao/Downloads/MySQL-python-1.2.5/setup.py install 

,但仍看到:

Traceback (most recent call last): 
    File "/Users/dandizhao/Downloads/MySQL-python-1.2.5/setup.py", line 17, in <module> 
    metadata, options = get_config() 
    File "/Users/dandizhao/Downloads/MySQL-python-1.2.5/setup_posix.py", line 32, in get_config 
    metadata, options = get_metadata_and_options() 
    File "/Users/dandizhao/Downloads/MySQL-python-1.2.5/setup_common.py", line 12, in get_metadata_and_options 
    metadata = dict(config.items('metadata')) 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ConfigParser.py", line 642, in items 
    raise NoSectionError(section) 
ConfigParser.NoSectionError: No section: 'metadata' 

真的筋疲力盡......我試過很多方法,我可以找到,但他們沒有工作......

回答

2

我去this link here,它看起來這是一個很常見問題與MySQL和MacOS。

給這些命令的嘗試在終端

$ brew uninstall mysql 
$ brew install mysql-connector-c 
$ brew unlink mysql-connector-c 
$ brew install mysql 
$ pip install mysql-python 
+0

哦,是的,非常感謝你!有用! –

+0

沒問題!不要忘記打綠色複選標記以接受答案是正確的。 @趙丹迪 – Lewis