在Mac OS上为python3安装mariadb的mysqlclient

时间:2017-05-29 09:47:15

标签: python django macos python-3.x mariadb

我在MAC OS Sierra上处理Python3的pip install mysqlclient时遇到问题。

running build_ext
building '_mysql' extension
creating build/temp.macosx-10.12-x86_64-3.6
clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/Cellar/openssl/1.0.2k/include -Dversion_info=(1,3,10,'final',0) -D__version__=1.3.10 -I/usr/local/Cellar/mariadb/10.2.6/include/mysql -I/usr/local/Cellar/mariadb/10.2.6/include/mysql/.. -I/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c _mysql.c -o build/temp.macosx-10.12-x86_64-3.6/_mysql.o
_mysql.c:1911:42: error: no member named 'reconnect' in 'struct st_mysql'
        if ( reconnect != -1 ) self->connection.reconnect = reconnect;
                               ~~~~~~~~~~~~~~~~ ^
1 error generated.
error: command 'clang' failed with exit status 1

我已安装MariaDB和xcode-select --install并已处理。

2 个答案:

答案 0 :(得分:18)

问题出现在mariadb 10.2.x mariadb 10.1.23 我安装{{1}没问题}。

因此,对于mysqlclient 10.2.x ,我们需要安装mariadb

mariadb-connector-c

更新:错误已在mysqlclient中修复(请参阅https://github.com/PyMySQL/mysqlclient-python/pull/177)但尚未发布

答案 1 :(得分:5)

SOLVE:

pip uninstall mysqlclient
pip install -U git+git://github.com/PyMySQL/mysqlclient-python