2017-06-05 59 views
0

我正在开发一个Python3.4/Django项目(在CentOS 6.8x64上)并试图安装mysqlclient驱动程序。尽管数小时的搜索,我无法弄清楚如何解决安装过程中看起来像编译错误。Linux上的mysqlclient pip故障

据我可以告诉我已经安装了所有必要的库包,但到目前为止没有运气。下面是输出(遗憾的冗长):

$ 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/ 
+1

这对我来说似乎是一个库兼容性的东西。是否有可能需要旧版本的mysqlclient? – Gadzooks34

回答

0

我猜你需要安装mysql-devel的或MariaDB的-devel的(如果是已经可以在CentOS 6)为了编译。

yum install mysql-devel 
+1

我以为也许这就是它,但我已经安装了它(MariaDB-devel.x86_64) – Gadzooks34

+0

我以为是一样的,我遇到了MariaDB的问题。我从MariaDB的角度进行了以下安装: $ sudo dnf list installed | grep“maria” mariadb mariadb-common mariadb-config mariadb-devel mariadb-errmsg mariadb-libs mariadb-server mariadb-server-utils – mjwittering

+0

其中很多我甚至都没有在回购列表中看到。我以为我从MariaDB网站添加了标准的。你有没有添加另一个? – Gadzooks34

0

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