【问题标题】:mysqlclient pip failure on LinuxLinux上的mysqlclient pip失败
【发布时间】:2017-06-05 17:26:46
【问题描述】:

我正在开发一个 Python3.4/Django 项目(在 CentOS 6.8x64 上)并尝试安装 mysqlclient 驱动程序。尽管进行了数小时的谷歌搜索,但我无法弄清楚如何在安装过程中找出看起来像编译错误的东西。

据我所知,我已经安装了所有必要的库包,但到目前为止还没有运气。这是输出(抱歉冗长):

$ sudo pip3 install mysqlclient
Collecting mysqlclient
  Using cached mysqlclient-1.3.10.tar.gz
Installing collected packages: mysqlclient
  Running setup.py install for mysqlclient ... error
    Complete output from command /usr/bin/python3.4 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-qqqgbh_2/mysqlclient/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-cwqrqsw1-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.4
    copying _mysql_exceptions.py -> build/lib.linux-x86_64-3.4
    creating build/lib.linux-x86_64-3.4/MySQLdb
    copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.4/MySQLdb
    copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.4/MySQLdb
    copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.4/MySQLdb
    copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.4/MySQLdb
    copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.4/MySQLdb
    copying MySQLdb/release.py -> build/lib.linux-x86_64-3.4/MySQLdb
    copying MySQLdb/times.py -> build/lib.linux-x86_64-3.4/MySQLdb
    creating build/lib.linux-x86_64-3.4/MySQLdb/constants
    copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants
    copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants
    copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants
    copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants
    copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants
    copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants
    copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants
    running build_ext
    building '_mysql' extension
    creating build/temp.linux-x86_64-3.4
    gcc -pthread -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(1,3,10,'final',0) -D__version__=1.3.10 -I/usr/include/mysql -I/usr/include/python3.4m -c _mysql.c -o build/temp.linux-x86_64-3.4/_mysql.o
    _mysql.c: In function ‘_mysql_ConnectionObject_ping’:
    _mysql.c:1911: error: ‘MYSQL’ has no member named ‘reconnect’
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python3.4 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-qqqgbh_2/mysqlclient/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-cwqrqsw1-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-qqqgbh_2/mysqlclient/

【问题讨论】:

  • 这对我来说似乎是一个库兼容性问题。我是否可能需要旧版本的 mysqlclient?

标签: python mysql linux django


【解决方案1】:

我想你需要安装 mysql-devel 或 mariadb-devel(如果在 centos 6 上已经可用的话)才能编译。

yum install mysql-devel

【讨论】:

  • 我想也许就是这样,但我已经安装了它 (MariaDB-devel.x86_64)
  • 我也是这么想的,我遇到了 MariaDB 的问题。从 MariaDB 的角度来看,我进行了以下安装... $ sudo dnf list installed | grep "maria" mariadb mariadb-common mariadb-config mariadb-devel mariadb-errmsg mariadb-libs mariadb-server mariadb-server-utils
  • 许多我什至没有在 repo 中列出。我以为我添加了 MariaDB 网站上的标准版本。您必须添加另一个吗?
【解决方案2】:

原来这是 mysqlclient 和最新版本的 MariaDB (10.2) 之间的兼容性问题。我调整了我的包 repo 以指向旧版本的 MariaDB(10.0 或 10.1)并安装了其中一个,然后 mysqlclient 构建和安装没有问题。

【讨论】:

    猜你喜欢
    • 2015-09-08
    • 1970-01-01
    • 2020-01-13
    • 2019-02-11
    • 2021-06-28
    • 1970-01-01
    • 2019-10-09
    • 2017-10-15
    • 1970-01-01
    相关资源
    最近更新 更多