2016-10-31 138 views
8

在Mac OS Sierra上,使用python2.7創建virtualenv並嘗試安裝mysqlclient以使用Django w/MySQL。我通過自制軟件安裝了MySQL 5.6。運行 「PIP安裝的mysql」 給出了這些錯誤:Mac OS Sierra virtualenv(python 2.7)pip安裝mysqlclient錯誤

Running setup.py bdist_wheel for mysqlclient ... error 
... 
13 warnings generated. 
    cc -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -Wl,-F. build/temp.macosx-10.12-intel-2.7/_mysql.o -L/usr/local/Cellar/mysql56/5.6.32/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.12-intel-2.7/_mysql.so 
    ld: library not found for -lssl 
    clang: error: linker command failed with exit code 1 (use -v to see invocation) 
    error: command 'cc' failed with exit status 1 

Failed building wheel for mysqlclient 
Command "...env2.7/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/nm/mqfwjt115q7g0lpvnx7sylwm0000gn/T/pip-build-tJmAVS/mysqlclient/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/nm/mqfwjt115q7g0lpvnx7sylwm0000gn/T/pip-xVuIu1-record/install-record.txt --single-version-externally-managed --compile --install-headers .../env2.7/include/site/python2.7/mysqlclient" failed with error code 1 in /private/var/folders/nm/mqfwjt115q7g0lpvnx7sylwm0000gn/T/pip-build-tJmAVS/mysqlclient/ 

任何幫助將不勝感激。

回答

20

答案是使用安裝開發工具:

xcode-select --install

+0

這對我有用。 –

+0

也爲我工作。我仍然在OS X El Capitan上,但有同樣的錯誤信息。 – kas

7

在我來說,我需要做的兩個步驟:

xcode-select --install 

爲@howevilweare說,也PIP安裝了BREW安裝openssl使用env命令:

env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip install mysqlclient 
+0

據我所知,這是讓macOS Sierra和Homebrew的openSSL一起工作的唯一方法。 – wst