无法在OSX中完成mysql-python安装

时间:2016-05-10 04:04:59

标签: python mysql macos pip clang

我试图让它发挥作用,但我没有成功。我试图通过运行:{/ p>来安装mysql-python

pip install mysql-python

但我总是收到此错误

clang: error: invalid version number in '-mmacosx-version-min=10.11'
error: command 'clang' failed with exit status 1

我用homebrew更新所有库,我已经安装了mysql。我还确保拥有最新的pip,xcode和xcode命令行工具。

我已搜索了几个小时,但我还没有找到方法来构建这个包。

如果有人遇到类似的情况,我会非常感谢你的指导。

Collecting mysql-python
Using cached MySQL-python-1.2.5.zip
Building wheels for collected packages: mysql-python
Running setup.py bdist_wheel for mysql-python ... error
Complete output from command /usr/local/opt/python/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/qh/38cj02sj1fb83lfnsd4x3jm40000gn/T/pip-build-lCuswO/mysql-python/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /var/folders/qh/38cj02sj1fb83lfnsd4x3jm40000gn/T/tmpFVHSn1pip-wheel- --python-tag cp27:
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.11-x86_64-2.7
copying _mysql_exceptions.py -> build/lib.macosx-10.11-x86_64-2.7
creating build/lib.macosx-10.11-x86_64-2.7/MySQLdb
copying MySQLdb/__init__.py -> build/lib.macosx-10.11-x86_64-2.7/MySQLdb
copying MySQLdb/converters.py -> build/lib.macosx-10.11-x86_64-2.7/MySQLdb
copying MySQLdb/connections.py -> build/lib.macosx-10.11-x86_64-2.7/MySQLdb
copying MySQLdb/cursors.py -> build/lib.macosx-10.11-x86_64-2.7/MySQLdb
copying MySQLdb/release.py -> build/lib.macosx-10.11-x86_64-2.7/MySQLdb
copying MySQLdb/times.py -> build/lib.macosx-10.11-x86_64-2.7/MySQLdb
creating build/lib.macosx-10.11-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.11-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.macosx-10.11-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.11-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.macosx-10.11-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.11-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.11-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.11-x86_64-2.7/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.macosx-10.11-x86_64-2.7
clang -fno-strict-aliasing -fno-common -dynamic -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/local/Cellar/mysql/5.7.12/include/mysql -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.11-x86_64-2.7/_mysql.o -fno-omit-frame-pointer
clang: error: invalid version number in '-mmacosx-version-min=10.11'
error: command 'clang' failed with exit status 1

2 个答案:

答案 0 :(得分:3)

这可能是因为未安装x-code

xcode-select --install

答案 1 :(得分:0)

你应该首先通过Homebrew安装MySQL,以使python-mysql在OS X上正常工作。

pip uninstall MySQL-python
brew install mysql
brew install mysql-connector-c
pip install MySQL-python

原始答案:MySQL-python on mac