2017-06-05 53 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構建和安裝沒有問題。