Linux

时间:2017-06-05 17:26:46

标签: python mysql linux django

我正在使用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/

2 个答案:

答案 0 :(得分:0)

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

yum install mysql-devel

答案 1 :(得分:0)

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