简体   繁体   English

错误:MySQL-python 的构建轮失败

[英]ERROR: Failed building wheel for MySQL-python

To meet requirements of a legacy Django app, I need to install MySQL-python==1.2.5 on a fresh virtualenv on Debian 9. However when I run为了满足旧版 Django 应用程序的要求,我需要在 Debian 9 上的全新 virtualenv 上安装MySQL-python==1.2.5 。但是当我运行时

pip install MySQL-python==1.2.5

I get this error:我收到此错误:

$ 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.

There is a similar question , but the suggestions there did not work for me.一个类似的问题,但那里的建议对我不起作用。

I had same issue.我有同样的问题。 I guess the mysql-python relies some files from mysql driver (or library?).我猜mysql-python依赖于 mysql 驱动程序(或库?)的一些文件。

  1. Make sure you don't run in Debian like me.确保你不像我一样在Debian 中运行。 The official python image such as python:2.7 was built on Debian. python:2.7等官方python镜像是在Debian上构建的。 It turns out that Debian 10 was shipped with MariaDB and there are some differences between its API and Mysql's API事实证明,Debian 10 附带了 MariaDB,它的 API 和 Mysql 的 API 之间存在一些差异

  2. For others, you can try the following commands to see if it works对于其他人,您可以尝试以下命令,看看是否有效

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM