无法在虚拟环境中安装MySQLdB

时间:2015-09-21 04:27:28

标签: django mysql-python

源码进入虚拟环境后。

我做了以下事情:

pip install django

pip install mysql-python

然后我遇到了跟​​随错误

Collecting MYSQL-python
Downloading MySQL-python-1.2.5.zip (108kB)
100% |████████████████████████████████| 110kB 387kB/s 
Installing collected packages: MYSQL-python
Running setup.py install for MYSQL-python
Complete output from command    /Users/hainingwang/Dropbox/websites/django_projects/CVbuilder/CVbuilder/bin/python -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-CEs0Af/MYSQL-python/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-xUvIl_-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/hainingwang/Dropbox/websites/django_projects/CVbuilder/CVbuilder/include/site/python2.7/MYSQL-python:
running install
running build
running build_py
creating build
creating build/lib.macosx-10.5-x86_64-2.7
copying _mysql_exceptions.py -> build/lib.macosx-10.5-x86_64-2.7
creating build/lib.macosx-10.5-x86_64-2.7/MySQLdb
copying MySQLdb/__init__.py -> build/lib.macosx-10.5-x86_64-2.7/MySQLdb
copying MySQLdb/converters.py -> build/lib.macosx-10.5-x86_64-2.7/MySQLdb
copying MySQLdb/connections.py -> build/lib.macosx-10.5-x86_64-2.7/MySQLdb
copying MySQLdb/cursors.py -> build/lib.macosx-10.5-x86_64-2.7/MySQLdb
copying MySQLdb/release.py -> build/lib.macosx-10.5-x86_64-2.7/MySQLdb
copying MySQLdb/times.py -> build/lib.macosx-10.5-x86_64-2.7/MySQLdb
creating build/lib.macosx-10.5-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.5-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.macosx-10.5-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.5-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.macosx-10.5-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.5-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.5-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.5-x86_64-2.7/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.macosx-10.5-x86_64-2.7
gcc -fno-strict-aliasing -I/Users/hainingwang/anaconda/include -arch x86_64 -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.6.24/include/mysql -I/Users/hainingwang/anaconda/include/python2.7 -c _mysql.c -o build/temp.macosx-10.5-x86_64-2.7/_mysql.o -g -fno-omit-frame-pointer -fno-strict-aliasing
In file included from _mysql.c:44:
/usr/local/Cellar/mysql/5.6.24/include/mysql/my_config.h:348:11: warning: 'SIZEOF_SIZE_T' macro redefined [-Wmacro-redefined]
  #define SIZEOF_SIZE_T  SIZEOF_LONG
          ^
/Users/hainingwang/anaconda/include/python2.7/pymacconfig.h:43:17: note: previous definition is here
#        define SIZEOF_SIZE_T           8
                ^
In file included from _mysql.c:44:
/usr/local/Cellar/mysql/5.6.24/include/mysql/my_config.h:442:9: warning: 'HAVE_WCSCOLL' macro redefined [-Wmacro-redefined]
#define HAVE_WCSCOLL
        ^
/Users/hainingwang/anaconda/include/python2.7/pyconfig.h:917:9: note: previous definition is here
#define HAVE_WCSCOLL 1
        ^
_mysql.c:1589:10: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
        if (how < 0 || how >= sizeof(row_converters)) {
            ~~~ ^ ~
3 warnings generated.
gcc -bundle -undefined dynamic_lookup -L/Users/hainingwang/anaconda/lib -arch x86_64 -arch x86_64 build/temp.macosx-10.5-x86_64-2.7/_mysql.o -L/usr/local/Cellar/mysql/5.6.24/lib -L/Users/hainingwang/anaconda/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.5-x86_64-2.7/_mysql.so
ld: library not found for -lgcc_s.10.5
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'gcc' failed with exit status 1

----------------------------------------
Command        "/Users/hainingwang/Dropbox/websites/django_projects/CVbuilder/CVbuilder/bin/python -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-CEs0Af/MYSQL-python/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-xUvIl_-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/hainingwang/Dropbox/websites/django_projects/CVbuilder/CVbuilder/include/site/python2.7/MYSQL-python" failed with error code 1 in /private/tmp/pip-build-CEs0Af/MYSQL-python

安装将在虚拟环境之外工作。

我在OSX 10.10.5上安装了python 2.7.10和Django 1.8.4。

感谢。

1 个答案:

答案 0 :(得分:0)

尝试更新最后一个XCode,然后安装命令行工具