2017-04-26 37 views
5

運行pip install mysql-python沒有可與PIP在MacOS 10.12.4

Collecting mysql-python 
    Using cached MySQL-python-1.2.5.zip 
    Complete output from command python setup.py egg_info: 
    Traceback (most recent call last): 
     File "<string>", line 1, in <module> 
     File "/private/var/folders/b_/xh05hxwd0lzc3rm858jsypdc0000gn/T/pip-build-AWDYaP/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/var/folders/b_/xh05hxwd0lzc3rm858jsypdc0000gn/T/pip-build-AWDYaP/mysql-python/ 

當安裝mysql-python的繼收到的錯誤,我身邊跟着重新安裝setuptools的在this後的指示,我從https://www.python.org/

重新安裝的Python

which -a python

/Library/Frameworks/Python.framework/Versions/2.7/bin/python 
/usr/local/bin/python 
/usr/bin/python 

的錯誤似乎自從安裝MacOS的10.12.4已發生更新已

回答

16

與此

brew install mysql 
pip install MySQL-python 
+3

感謝您的解決方案。這讓我瘋狂。其實我必須做你的和其他人:brew unlink mysql-connector-c然後brew安裝mysql –

3

解決了。如果你和我一樣,安裝在MAC源的MySQL,然後忘了誰是建議使用BREW - 您的機器上已使用mysql-connector-C。如果你沒有安裝mysql-connector-c,那麼請先brew卸載mysql-connector-c,然後再次嘗試安裝mysql-python(對於我來說,因爲我使用的是Python 3,因此安裝了mysqlclient)。

1

如果仍然像「失敗的建築輪的mysql-python的」失敗,嘗試

LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysql-python 

它就像一個魅力對我來說。