2015-09-21 113 views
1

將源代碼放入虛擬環境後。無法在虛擬環境中安裝MySQLdB

我也做了以下內容:

pip install django 

pip install mysql-python 

然後,我碰上followign錯誤

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。

謝謝。

回答

0

嘗試更新最後一個XCode,然後安裝命令行工具

+0

感謝您的回答,它部分解決了問題。但事實證明,我仍然缺少一些庫,我認爲它與我的anaconda有關。所以我只需安裝python而不使用anaconda並且它可以工作。 – user2990903

+0

你可以接受答案,並給我一個upvote? 我很感激 –

相關問題