Python Mac installation mysqlclient package error “error: command ‘clang’ failed with exit status 1” solution
install mysqlclient package on Mac today always report an error, facing baidu to solve the problem for a long time finally solved, so put down the solution
PIP installation command
pip install mysqlclient
error
Building wheels for collected packages: mysqlclient
Building wheel for mysqlclient (setup.py) ... error
ERROR: Complete output from command /Users/xxx/virtualSpaces/flask_info/bin/python3.7 -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/jg/_5c6yf2x2b721htvf0h3vvlm0000gn/T/pip-install-vke00caa/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/jg/_5c6yf2x2b721htvf0h3vvlm0000gn/T/pip-wheel-voixgzfs --python-tag cp37:
ERROR: running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.14-x86_64-3.7
copying _mysql_exceptions.py -> build/lib.macosx-10.14-x86_64-3.7
creating build/lib.macosx-10.14-x86_64-3.7/MySQLdb
copying MySQLdb/__init__.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb
copying MySQLdb/compat.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb
copying MySQLdb/connections.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb
copying MySQLdb/converters.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb
copying MySQLdb/cursors.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb
copying MySQLdb/release.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb
copying MySQLdb/times.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb
creating build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.macosx-10.14-x86_64-3.7
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -Dversion_info=(1,3,13,'final',0) -D__version__=1.3.13 -I/usr/local/include -I/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c _mysql.c -o build/temp.macosx-10.14-x86_64-3.7/_mysql.o
_mysql.c:257:6: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
s = PyUnicode_AsUTF8(item);
^ ~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:287:6: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
s = PyUnicode_AsUTF8(item);
^ ~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:564:3: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
_stringsuck(ca, value, ssl);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:553:16: note: expanded from macro '_stringsuck'
if(t){d=PyUnicode_AsUTF8(t);ssl_keepref[n_ssl_keepref++]=t;}\
^~~~~~~~~~~~~~~~~~~~
_mysql.c:565:3: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
_stringsuck(capath, value, ssl);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:553:16: note: expanded from macro '_stringsuck'
if(t){d=PyUnicode_AsUTF8(t);ssl_keepref[n_ssl_keepref++]=t;}\
^~~~~~~~~~~~~~~~~~~~
_mysql.c:566:3: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
_stringsuck(cert, value, ssl);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:553:16: note: expanded from macro '_stringsuck'
if(t){d=PyUnicode_AsUTF8(t);ssl_keepref[n_ssl_keepref++]=t;}\
^~~~~~~~~~~~~~~~~~~~
_mysql.c:567:3: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
_stringsuck(key, value, ssl);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:553:16: note: expanded from macro '_stringsuck'
if(t){d=PyUnicode_AsUTF8(t);ssl_keepref[n_ssl_keepref++]=t;}\
^~~~~~~~~~~~~~~~~~~~
_mysql.c:568:3: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
_stringsuck(cipher, value, ssl);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:553:16: note: expanded from macro '_stringsuck'
if(t){d=PyUnicode_AsUTF8(t);ssl_keepref[n_ssl_keepref++]=t;}\
^~~~~~~~~~~~~~~~~~~~
_mysql.c:2530:8: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
cname = PyUnicode_AsUTF8(name);
^ ~~~~~~~~~~~~~~~~~~~~~~
8 warnings generated.
clang -bundle -undefined dynamic_lookup build/temp.macosx-10.14-x86_64-3.7/_mysql.o -L/usr/local/Cellar/mysql-connector-c/6.1.11/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.14-x86_64-3.7/_mysql.cpython-37m-darwin.so
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for mysqlclient
Running setup.py clean for mysqlclient
Failed to build mysqlclient
Running setup.py install for mysqlclient ... error
ERROR: Complete output from command /Users/xxx/virtualSpaces/flask_info/bin/python3.7 -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/jg/_5c6yf2x2b721htvf0h3vvlm0000gn/T/pip-install-vke00caa/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 /private/var/folders/jg/_5c6yf2x2b721htvf0h3vvlm0000gn/T/pip-record-nq6eazu6/install-record.txt --single-version-externally-managed --compile --install-headers /Users/xxx/virtualSpaces/flask_info/bin/../include/site/python3.7/mysqlclient:
ERROR: running install
running build
running build_py
creating build
creating build/lib.macosx-10.14-x86_64-3.7
copying _mysql_exceptions.py -> build/lib.macosx-10.14-x86_64-3.7
creating build/lib.macosx-10.14-x86_64-3.7/MySQLdb
copying MySQLdb/__init__.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb
copying MySQLdb/compat.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb
copying MySQLdb/connections.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb
copying MySQLdb/converters.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb
copying MySQLdb/cursors.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb
copying MySQLdb/release.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb
copying MySQLdb/times.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb
creating build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.macosx-10.14-x86_64-3.7
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -Dversion_info=(1,3,13,'final',0) -D__version__=1.3.13 -I/usr/local/include -I/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c _mysql.c -o build/temp.macosx-10.14-x86_64-3.7/_mysql.o
_mysql.c:257:6: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
s = PyUnicode_AsUTF8(item);
^ ~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:287:6: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
s = PyUnicode_AsUTF8(item);
^ ~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:564:3: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
_stringsuck(ca, value, ssl);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:553:16: note: expanded from macro '_stringsuck'
if(t){d=PyUnicode_AsUTF8(t);ssl_keepref[n_ssl_keepref++]=t;}\
^~~~~~~~~~~~~~~~~~~~
_mysql.c:565:3: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
_stringsuck(capath, value, ssl);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:553:16: note: expanded from macro '_stringsuck'
if(t){d=PyUnicode_AsUTF8(t);ssl_keepref[n_ssl_keepref++]=t;}\
^~~~~~~~~~~~~~~~~~~~
_mysql.c:566:3: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
_stringsuck(cert, value, ssl);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:553:16: note: expanded from macro '_stringsuck'
if(t){d=PyUnicode_AsUTF8(t);ssl_keepref[n_ssl_keepref++]=t;}\
^~~~~~~~~~~~~~~~~~~~
_mysql.c:567:3: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
_stringsuck(key, value, ssl);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:553:16: note: expanded from macro '_stringsuck'
if(t){d=PyUnicode_AsUTF8(t);ssl_keepref[n_ssl_keepref++]=t;}\
^~~~~~~~~~~~~~~~~~~~
_mysql.c:568:3: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
_stringsuck(cipher, value, ssl);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:553:16: note: expanded from macro '_stringsuck'
if(t){d=PyUnicode_AsUTF8(t);ssl_keepref[n_ssl_keepref++]=t;}\
^~~~~~~~~~~~~~~~~~~~
_mysql.c:2530:8: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
cname = PyUnicode_AsUTF8(name);
^ ~~~~~~~~~~~~~~~~~~~~~~
8 warnings generated.
clang -bundle -undefined dynamic_lookup build/temp.macosx-10.14-x86_64-3.7/_mysql.o -L/usr/local/Cellar/mysql-connector-c/6.1.11/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.14-x86_64-3.7/_mysql.cpython-37m-darwin.so
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1
----------------------------------------
ERROR: Command "/Users/xxx/virtualSpaces/flask_info/bin/python3.7 -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/jg/_5c6yf2x2b721htvf0h3vvlm0000gn/T/pip-install-vke00caa/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 /private/var/folders/jg/_5c6yf2x2b721htvf0h3vvlm0000gn/T/pip-record-nq6eazu6/install-record.txt --single-version-externally-managed --compile --install-headers /Users/xxx/virtualSpaces/flask_info/bin/../include/site/python3.7/mysqlclient" failed with error code 1 in /private/var/folders/jg/_5c6yf2x2b721htvf0h3vvlm0000gn/T/pip-install-vke00caa/mysqlclient/
solution
Github gives brew info openssl
explanation:
solves the problem by adding environment variables:
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
After
, execute the installation command again to
pip install mysqlclient
I installed the reset.txt file directly on my side, but with little difference.
official making related issue solution:
reference: https://github.com/PyMySQL/mysqlclient-python/issues/169 https://www.jianshu.com/p/d4a349a7e7f5
p>
Read More:
- Python Mac installs mysqlclient package error “error: command’clang’ failed with exit status 1” solution
- Error: Command ‘/ usr / bin / clang’ failed with exit status 1 solution for Mac OS installation
- Install Python package under MacOS: “error: Command ‘GCC’ failed with exit status 1”
- Error: command error out with exit status 1: Python when installing mysqlclient in django2.0 setup.py egg_ info
- Error: command error out with exit status 1: Python when installing mysqlclient in centos7 setup.py egg_ info Check
- command ‘x86_64-linux-gnu-gcc’ failed with exit status 1
- ubuntu install mysqlclient error ERROR: Failed building wheel for mysqlclient solution
- Python installation problem: error: Command erred out with exit status 1:
- error: command ‘arm-linux-gnueabihf-gcc’ failed with exit status 1, Raspberry Pi installation paramiko
- clang: error: linker command failed with exit code 1 (use -v to see invocation)
- Command errored out with exit status 1: python setup.py egg_info Check the logs for full command ou
- ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full comm
- Xcode ffmpeg Error:/clang:1:1: linker command failed with exit code 1 (use -v to see invocation)
- iOS clang: error: linker command failed with exit code 1 (use -v to see invocation)
- How does a Mac terminal exit the python command line
- Ubuntu16.04 pip3 install PyAudio 出错:error: command ‘x86_64-linux-gnu-gcc’ failed with exit status 1
- Python error: command error out with exit status 1:
- command ‘gcc‘ failed with exit status 4
- Beatifulsoup MAC installation solution Python 3
- Error: command error out with exit status 1: Python setup.py egg_ inf