簡體   English   中英

Linux上的mysqlclient pip失敗

[英]mysqlclient pip failure on Linux

我正在研究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/

我猜您需要安裝mysql-devel或mariadb-devel(如果在centos 6上已經可用)才能進行編譯。

yum install mysql-devel

原來這是mysqlclient和最新版本的MariaDB(10.2)之間的兼容性問題。 我調整了軟件包的存儲庫,使其指向較舊的MariaDB版本(10.0或10.1),並安裝了其中一個版本,然后mysqlclient構建並安裝沒有問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM