python - pip install mysql-python错误

标签 python mysql pip

当我这样做时:

pip install mysql-python

我得到下面的输出,它只是挂起。这是在MacOSX10.9.3上的Python2.7Virtualenv中完成的。在升级到10.9.x之后,似乎开始发生很多奇怪的事情。任何帮助都将非常感谢。
Installing collected packages: mysql-python
  Running setup.py install for mysql-python
    building '_mysql' extension
    cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/local/Cellar/mysql/5.6.17/include/mysql -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.9-intel-2.7/_mysql.o -Os -g -fno-strict-aliasing
    In file included from _mysql.c:44:
    /usr/local/Cellar/mysql/5.6.17/include/mysql/my_config.h:348:11: warning: 'SIZEOF_SIZE_T' macro redefined
      #define SIZEOF_SIZE_T  SIZEOF_LONG
              ^
    /System/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.17/include/mysql/my_config.h:442:9: warning: 'HAVE_WCSCOLL' macro redefined
    #define HAVE_WCSCOLL
            ^
    /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pyconfig.h:906:9: note: previous definition is here
    #define HAVE_WCSCOLL 1
            ^
    _mysql.c:287:14: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
                    cmd_argc = PySequence_Size(cmd_args);
                             ~ ^~~~~~~~~~~~~~~~~~~~~~~~~
    _mysql.c:317:12: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
                    groupc = PySequence_Size(groups);
                           ~ ^~~~~~~~~~~~~~~~~~~~~~~
    _mysql.c:470:14: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
                            int j, n2=PySequence_Size(fun);
                                   ~~ ^~~~~~~~~~~~~~~~~~~~
    _mysql.c:1127:9: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
                    len = mysql_real_escape_string(&(self->connection), out, in, size);
                        ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    _mysql.c:1129:9: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
                    len = mysql_escape_string(out, in, size);
                        ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    _mysql.c:1168:9: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
            size = PyString_GET_SIZE(s);
                 ~ ^~~~~~~~~~~~~~~~~~~~
    /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/stringobject.h:92:32: note: expanded from macro 'PyString_GET_SIZE'
    #define PyString_GET_SIZE(op)  Py_SIZE(op)
                                   ^~~~~~~~~~~
    /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/object.h:116:56: note: expanded from macro 'Py_SIZE'
    #define Py_SIZE(ob)             (((PyVarObject*)(ob))->ob_size)
                                     ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
    _mysql.c:1178:9: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
                    len = mysql_real_escape_string(&(self->connection), out+1, in, size);
                        ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    _mysql.c:1180:9: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
                    len = mysql_escape_string(out+1, in, size);
                        ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    _mysql.c:1274:11: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
            if ((n = PyObject_Length(o)) == -1) goto error;
                   ~ ^~~~~~~~~~~~~~~~~~
    /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/abstract.h:434:25: note: expanded from macro 'PyObject_Length'
    #define PyObject_Length PyObject_Size
                            ^
    _mysql.c:1466:10: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
                            len = strlen(buf);
                                ~ ^~~~~~~~~~~
    _mysql.c:1468:10: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
                            len = strlen(buf);
                                ~ ^~~~~~~~~~~
    _mysql.c:1504:11: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
                                    len = strlen(buf);
                                        ~ ^~~~~~~~~~~
    _mysql.c:1506:11: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
                                    len = strlen(buf);
                                        ~ ^~~~~~~~~~~
    _mysql.c:1589:10: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
            if (how < 0 || how >= sizeof(row_converters)) {
                ~~~ ^ ~
    16 warnings generated.
    In file included from _mysql.c:44:
    /usr/local/Cellar/mysql/5.6.17/include/mysql/my_config.h:348:11: warning: 'SIZEOF_SIZE_T' macro redefined
      #define SIZEOF_SIZE_T  SIZEOF_LONG
              ^
    /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pymacconfig.h:56:17: note: previous definition is here
    #        define SIZEOF_SIZE_T           4
                    ^
    In file included from _mysql.c:44:
    /usr/local/Cellar/mysql/5.6.17/include/mysql/my_config.h:442:9: warning: 'HAVE_WCSCOLL' macro redefined
    #define HAVE_WCSCOLL
            ^
    /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pyconfig.h:906:9: note: previous definition is here
    #define HAVE_WCSCOLL 1
            ^
    In file included from _mysql.c:44:
    /usr/local/Cellar/mysql/5.6.17/include/mysql/my_config.h:661:9: warning: 'SIZEOF_TIME_T' macro redefined
    #define SIZEOF_TIME_T 8
            ^
    /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pymacconfig.h:57:17: note: previous definition is here
    #        define SIZEOF_TIME_T           4
                    ^
    _mysql.c:1589:10: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
            if (how < 0 || how >= sizeof(row_converters)) {
                ~~~ ^ ~
    4 warnings generated.

最佳答案

尝试sudo pip install mysqlclient
当您将项目移植到python 3时,您将被覆盖sudo pip3 install...

关于python - pip install mysql-python错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24166930/

相关文章:

python - 如何在不安装 Oracle 客户端和 cx_Oracle 的情况下访问 Oracle 数据库?

java - 如何在java中创建带有多个可选where子句的搜索语句?

php - MySQL 5.5 到 5.7 停止使用索引

python - 无法通过 PyPI 中的 pip 安装最新版本的软件包

python - Python的python-daemon和daemonize有什么区别?

python - 如何在 pandas 中重新存储而不是分组间隔

python - 查找数组中每个索引左侧/右侧的 Argmin

python - urllib.request : POST data should be bytes, 一个可迭代的字节,或者一个文件对象

mysql - 使用 Dynamic MAX(date) 选择两个日期之间的所有行

python - 安装 Python 包时选择 pip 与 conda 的具体原因