mac下安装mysqlcient 报错

一、我在mac下pip3安装mysqlclient 报错:

 pip3 install mysqlclient
Collecting mysqlclient
  Using cached mysqlclient-1.3.12.tar.gz
Installing collected packages: mysqlclient
  Running setup.py install for mysqlclient ... error
    Complete output from command /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-1ecj4utc/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-442qoq4k-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.6-intel-3.6
    copying _mysql_exceptions.py -> build/lib.macosx-10.6-intel-3.6
    creating build/lib.macosx-10.6-intel-3.6/MySQLdb
    copying MySQLdb/__init__.py -> build/lib.macosx-10.6-intel-3.6/MySQLdb
    copying MySQLdb/compat.py -> build/lib.macosx-10.6-intel-3.6/MySQLdb
    copying MySQLdb/connections.py -> build/lib.macosx-10.6-intel-3.6/MySQLdb
    copying MySQLdb/converters.py -> build/lib.macosx-10.6-intel-3.6/MySQLdb
    copying MySQLdb/cursors.py -> build/lib.macosx-10.6-intel-3.6/MySQLdb
    copying MySQLdb/release.py -> build/lib.macosx-10.6-intel-3.6/MySQLdb
    copying MySQLdb/times.py -> build/lib.macosx-10.6-intel-3.6/MySQLdb
    creating build/lib.macosx-10.6-intel-3.6/MySQLdb/constants
    copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.6-intel-3.6/MySQLdb/constants
    copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.6-intel-3.6/MySQLdb/constants
    copying MySQLdb/constants/CR.py -> build/lib.macosx-10.6-intel-3.6/MySQLdb/constants
    copying MySQLdb/constants/ER.py -> build/lib.macosx-10.6-intel-3.6/MySQLdb/constants
    copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.6-intel-3.6/MySQLdb/constants
    copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.6-intel-3.6/MySQLdb/constants
    copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.6-intel-3.6/MySQLdb/constants
    running build_ext
    building '_mysql' extension
    creating build/temp.macosx-10.6-intel-3.6
    /usr/bin/clang -fno-strict-aliasing -Wsign-compare -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -Dversion_info=(1,3,12,'final',0) -D__version__=1.3.12 -I/usr/local/mysql/include -I/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c _mysql.c -o build/temp.macosx-10.6-intel-3.6/_mysql.o
    In file included from _mysql.c:29:
    In file included from /usr/local/mysql/include/mysql.h:71:
    In file included from /usr/local/mysql/include/mysql_com.h:995:
    /usr/local/mysql/include/mysql/udf_registration_types.h:79:28: warning: this function declaration is not a prototype [-Wstrict-prototypes]
    typedef void(*Udf_func_any)();
                               ^
                                void
    _mysql.c:1894:3: error: use of undeclared identifier 'my_bool'
                    my_bool recon = reconnect;
                    ^
    _mysql.c:1895:58: error: use of undeclared identifier 'recon'
                    mysql_options(&self->connection, MYSQL_OPT_RECONNECT, &recon);
                                                                           ^
    1 warning and 2 errors generated.
    error: command '/usr/bin/clang' failed with exit status 1
    
    ----------------------------------------
Command "/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-1ecj4utc/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-442qoq4k-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-1ecj4utc/mysqlclient/
sh-3.2# file /usr/bin/clang

 

 

二、报错原因:

  1、之前还安装成功的、从新安装了一下python3.6然后安装mysqlclient就不行了、最后确认是mac上的mysq-8.0.3引起的

  于是把mysql-8.0.3 回滚到了mysql-5.7-16 安装完成了。

 

三、安装完成:

pip3 install mysqlclient
Collecting mysqlclient
  Using cached mysqlclient-1.3.12.tar.gz
Installing collected packages: mysqlclient
  Running setup.py install for mysqlclient ... done
Successfully installed mysqlclient-1.3.12

 

点赞