【问题标题】:ERROR: Failed building wheel for MySQL-python错误:MySQL-python 的构建轮子失败
【发布时间】:2019-12-07 22:16:49
【问题描述】:

为了满足旧版 Django 应用程序的要求,我需要在 Debian 9 上的全新 virtualenv 上安装 MySQL-python==1.2.5。但是当我运行时

pip install MySQL-python==1.2.5

我收到此错误:

$ pip install MySQL-python==1.2.5
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting MySQL-python==1.2.5
  Using cached https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip
Building wheels for collected packages: MySQL-python
  Building wheel for MySQL-python (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/bob/.dj/bin/python2 -u -c 'import sys, setuptools, ...
  ----------------------------------------
  ERROR: Failed building wheel for MySQL-python
 ...
    In file included from _mysql.c:44:
    /usr/include/mariadb/my_config.h:3:2: warning: #warning This file should not be included by clients, include only <mysql.h> [-Wcpp]
     #warning This file should not be included by clients, include only <mysql.h>
      ^~~~~~~
    In file included from _mysql.c:46:
    /usr/include/mariadb/mysql.h:440:3: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
       MYSQL_CLIENT_PLUGIN_HEADER
       ^~~~~~~~~~~~~~~~~~~~~~~~~~
    _mysql.c: In function ‘_mysql_ConnectionObject_ping’:
    _mysql.c:2005:41: error: ‘MYSQL’ {aka ‘struct st_mysql’} has no member named ‘reconnect’
      if ( reconnect != -1 ) self->connection.reconnect = reconnect;
                                             ^
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/bob/.dj/bin/python2 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-29DwM6/MySQL-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-29DwM6/MySQL-python/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-nI8a9C/install-record.txt --single-version-externally-managed --compile --install-headers /home/bob/.dj/include/site/python2.7/MySQL-python Check the logs for full command output.

a similar question,但那里的建议对我不起作用。

【问题讨论】:

    标签: python mysql python-2.7 mysql-python


    【解决方案1】:

    我有同样的问题。我猜mysql-python 依赖于一些来自 mysql 驱动程序(或库?)的文件。

    1. 确保您不像我一样在 Debian 中运行。官方python镜像如python:2.7 建立在 Debian 上。事实证明,Debian 10 是随 MariaDB 一起发布的,它的 API 和 Mysql 的 API 之间存在一些差异

    2. 对于其他人,你可以试试下面的命令看看是否有效

      # on Mac
      brew install mysql-connector-c 
      brew install mysql@5.7
      
      # on Ubuntu
      apt-get install -y default-libmysqlclient-dev
      

    【讨论】:

      猜你喜欢
      • 2017-09-11
      • 1970-01-01
      • 2019-11-03
      • 2018-12-09
      • 2020-12-28
      • 2021-04-25
      • 1970-01-01
      • 2016-11-14
      • 2022-01-10
      相关资源
      最近更新 更多