要满足旧版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,但那里的建议对我没有用。
答案 0 :(得分:0)
我有同样的问题。我猜 mysql-python
依赖于来自 mysql 驱动程序(或库?)的一些文件。
确保您不会像我一样在 Debian 中运行。官方python镜像如python:2.7 是建立在 Debian 上的。事实证明,Debian 10 附带了 MariaDB,其 API 与 Mysql 的 API 之间存在一些差异
对于其他人,您可以尝试以下命令,看看是否有效
# on Mac
brew install mysql-connector-c
brew install mysql@5.7
# on Ubuntu
apt-get install -y default-libmysqlclient-dev