Python Mac安装 mysqlclient 包报错“error: command 'clang' failed with exit status 1”解决办法
2019-05-22 17:06
1336 查看
Python Mac安装 mysqlclient 包报错“error: command ‘clang’ failed with exit status 1”解决办法
今天在 Mac 上安装 mysqlclient 包总是报错,面向度娘解决问题找了好久终于解决,所以把解决的方法记录下来
pip安装命令
pip install mysqlclient
错误提示
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 m 1cca8 ysqlclient 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/
解决办法
Github给出
brew info openssl的解释:
通过添加环境变量解决问题:
export LDFLAGS="-L/usr/local/opt/openssl/lib" export CPPFLAGS="-I/usr/local/opt/openssl/include"
之后再次执行安装命令即可
pip install mysqlclient
我这边是直接安装 requirement.txt 文件,不过区别不大。
官方github相关issue的解决方法:
https://github.com/PyMySQL/mysqlclient-python/issues/169
参考:
https://www.jianshu.com/p/d4a349a7e7f5
相关文章推荐
- MAC安装python模块碰到“error: command 'cc' failed with exit status 1”解决办法
- CentOS7上 pip install MySQL-python 安装失败(error: command 'gcc' failed with exit status 1)的解决办法
- mac下安装mysql-python包报unable to execute llvm-gcc-4.2: No such file or directory error: command 'llvm-gcc-4.2' failed with exit status 1解决方法
- 安装python-MySQLdb 出现error: command 'gcc' failed with exit status 1的解决方法
- 关于Python安装模块出现error: command 'gcc' failed with exit status 1错误的解决方法
- 在Mac上安装pyspider时出现 error: command 'cc' failed with exit status 1 的解决方法
- 关于Python安装模块出现error: command 'gcc' failed with exit status 1错误的解决方法
- 解决Python扩展程序编译安装的error: command 'mt.exe' failed with exit status 31
- centos7.3安装paramiko报error: command 'gcc' failed with exit status 1的解决办法
- centos7.2安装paramiko报error: command 'gcc' failed with exit status 1的解决办法
- 关于python 安装lxml-4.1.1 报 error: command 'gcc' failed with exit status 1
- [CentOS]安装MySQL-python,error: Setup script exited with error: command 'gcc' failed with exit status
- error: command 'gcc' failed with exit status 4 问题的解决办法
- clang: error: linker command failed with exit code 1 (use -v to see invocation) 解决办法
- 安装MySQL-python时发生错误:error: command 'gcc' failed with exit status 1
- clang: error: linker command failed with exit code 1 (use -v to see invocation)解决办法
- python安装模块的时候报错error: command 'gcc' failed with exit status 1
- 安装python模块时出现:error: Setup script exited with error: command 'gcc' failed with exit status 1
- Centos python3安装paramiko出现error: command 'gcc' failed with exit status 1
- 安装MySQL-python-1.2.3c1出现“error: command 'gcc' failed with exit status 1”错误