在OSX,virtualenv中使用pip install安装MySQL-python时出错 [英] Error when installing MySQL-python with pip install in OSX, virtualenv

查看:96
本文介绍了在OSX,virtualenv中使用pip install安装MySQL-python时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,当我尝试使用以下命令运行服务器时,我正在开发django应用程序:

First i'm developing a django app, when i try to run the server with:

python manage.py runserver 0.0.0.0:8000

python manage.py runserver 0.0.0.0:8000

终端显示:

 "django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb"

因此,我需要安装该软件包:

So, i need to install that package:

(app1)Me% pip install MySQL-python

错误:

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
  Complete output from command /Users/GFTecla/Documents/shoutout/bin/python -c "import setuptools;__file__='/private/var/folders/9g/1qrws9yj3wn7lghlrpgyh9cc0000gn/T/pip-build-ZMQOQm/mysql-python/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /var/folders/9g/1qrws9yj3wn7lghlrpgyh9cc0000gn/T/tmp1JfTpfpip-wheel-:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.5-intel-2.7
  copying _mysql_exceptions.py -> build/lib.macosx-10.5-intel-2.7
  creating build/lib.macosx-10.5-intel-2.7/MySQLdb
  copying MySQLdb/__init__.py -> build/lib.macosx-10.5-intel-2.7/MySQLdb
  copying MySQLdb/converters.py -> build/lib.macosx-10.5-intel-2.7/MySQLdb
  copying MySQLdb/connections.py -> build/lib.macosx-10.5-intel-2.7/MySQLdb
  copying MySQLdb/cursors.py -> build/lib.macosx-10.5-intel-2.7/MySQLdb
  copying MySQLdb/release.py -> build/lib.macosx-10.5-intel-2.7/MySQLdb
  copying MySQLdb/times.py -> build/lib.macosx-10.5-intel-2.7/MySQLdb
  creating build/lib.macosx-10.5-intel-2.7/MySQLdb/constants
  copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.5-intel-2.7/MySQLdb/constants
  copying MySQLdb/constants/CR.py -> build/lib.macosx-10.5-intel-2.7/MySQLdb/constants
  copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.5-intel-2.7/MySQLdb/constants
  copying MySQLdb/constants/ER.py -> build/lib.macosx-10.5-intel-2.7/MySQLdb/constants
  copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.5-intel-2.7/MySQLdb/constants
  copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.5-intel-2.7/MySQLdb/constants
  copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.5-intel-2.7/MySQLdb/constants
  running build_ext
  building '_mysql' extension
  creating build/temp.macosx-10.5-intel-2.7
  gcc -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/local/Cellar/mysql/5.6.23/include/mysql -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.5-intel-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.23/include/mysql/my_config.h:348:11: warning: 'SIZEOF_SIZE_T' macro redefined
    #define SIZEOF_SIZE_T  SIZEOF_LONG
            ^
  /Library/Frameworks/Python.framework/Versions/2.7/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.23/include/mysql/my_config.h:442:9: warning: 'HAVE_WCSCOLL' macro redefined
  #define HAVE_WCSCOLL
          ^
  /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pyconfig.h:911: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 -arch i386 -arch x86_64 -isysroot / -Qunused-arguments -Qunused-arguments build/temp.macosx-10.5-intel-2.7/_mysql.o -L/usr/local/Cellar/mysql/5.6.23/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.5-intel-2.7/_mysql.so
  ld: library not found for -lbundle1.o
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  error: command 'gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for mysql-python
Failed to build mysql-python
Installing collected packages: mysql-python
  Running setup.py install for mysql-python
    Complete output from command /Users/GFTecla/Documents/shoutout/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/9g/1qrws9yj3wn7lghlrpgyh9cc0000gn/T/pip-build-ZMQOQm/mysql-python/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/9g/1qrws9yj3wn7lghlrpgyh9cc0000gn/T/pip-YOrOKA-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/GFTecla/Documents/shoutout/bin/../include/site/python2.7/mysql-python:
    running install
    running build
    running build_py
    copying MySQLdb/release.py -> build/lib.macosx-10.5-intel-2.7/MySQLdb
    running build_ext
    building '_mysql' extension
    gcc -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/local/Cellar/mysql/5.6.23/include/mysql -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.5-intel-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.23/include/mysql/my_config.h:348:11: warning: 'SIZEOF_SIZE_T' macro redefined
      #define SIZEOF_SIZE_T  SIZEOF_LONG
              ^
    /Library/Frameworks/Python.framework/Versions/2.7/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.23/include/mysql/my_config.h:442:9: warning: 'HAVE_WCSCOLL' macro redefined
    #define HAVE_WCSCOLL
            ^
    /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pyconfig.h:911: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 -arch i386 -arch x86_64 -isysroot / -Qunused-arguments -Qunused-arguments build/temp.macosx-10.5-intel-2.7/_mysql.o -L/usr/local/Cellar/mysql/5.6.23/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.5-intel-2.7/_mysql.so
    ld: library not found for -lbundle1.o
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/Users/GFTecla/Documents/shoutout/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/9g/1qrws9yj3wn7lghlrpgyh9cc0000gn/T/pip-build-ZMQOQm/mysql-python/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/9g/1qrws9yj3wn7lghlrpgyh9cc0000gn/T/pip-YOrOKA-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/GFTecla/Documents/shoutout/bin/../include/site/python2.7/mysql-python" failed with error code 1 in /private/var/folders/9g/1qrws9yj3wn7lghlrpgyh9cc0000gn/T/pip-build-ZMQOQm/mysql-python

我有OS X 10.10.2

I have OS X 10.10.2

Django 1.8.2

Django 1.8.2

Python 2.7

Python 2.7

推荐答案

解决方案是重新安装开发人员工具:

The solution was in reinstalling the developer tools:

xcode-select --install

这篇关于在OSX,virtualenv中使用pip install安装MySQL-python时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆