系统:MacOS 10.14.3
python:3.7.3
mysql:5.7.25(由brewhome安装:brew install mysql@5.7
)
当我使用pip install myclient
时,我得到了以下错误跟踪:
ERROR: Complete output from command /Users/zhaokun/Documents/Python/www/venv/django_site/bin/python3.7 -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/ns/sj62hbw56cv68873x8_ck7gh0000gn/T/pip-install-vjn6m8ro/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/ns/sj62hbw56cv68873x8_ck7gh0000gn/T/pip-wheel-hom1hl9x --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,12,'final',0) -D__version__=1.3.12 -I/usr/local/opt/mysql@5.7/include/mysql -I/usr/local/Cellar/python/3.7.3/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:252:6: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
s = PyUnicode_AsUTF8(item);
^ ~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:282:6: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
s = PyUnicode_AsUTF8(item);
^ ~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:571:3: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
_stringsuck(ca, value, ssl);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:560:16: note: expanded from macro '_stringsuck'
if(t){d=PyUnicode_AsUTF8(t);ssl_keepref[n_ssl_keepref++]=t;}\
^~~~~~~~~~~~~~~~~~~~
_mysql.c:572:3: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
_stringsuck(capath, value, ssl);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:560:16: note: expanded from macro '_stringsuck'
if(t){d=PyUnicode_AsUTF8(t);ssl_keepref[n_ssl_keepref++]=t;}\
^~~~~~~~~~~~~~~~~~~~
_mysql.c:573:3: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
_stringsuck(cert, value, ssl);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:560:16: note: expanded from macro '_stringsuck'
if(t){d=PyUnicode_AsUTF8(t);ssl_keepref[n_ssl_keepref++]=t;}\
^~~~~~~~~~~~~~~~~~~~
_mysql.c:574:3: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
_stringsuck(key, value, ssl);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:560:16: note: expanded from macro '_stringsuck'
if(t){d=PyUnicode_AsUTF8(t);ssl_keepref[n_ssl_keepref++]=t;}\
^~~~~~~~~~~~~~~~~~~~
_mysql.c:575:3: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
_stringsuck(cipher, value, ssl);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:560:16: note: expanded from macro '_stringsuck'
if(t){d=PyUnicode_AsUTF8(t);ssl_keepref[n_ssl_keepref++]=t;}\
^~~~~~~~~~~~~~~~~~~~
_mysql.c:2589: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/opt/mysql@5.7/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
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error
ERROR: Complete output from command /Users/zhaokun/Documents/Python/www/venv/django_site/bin/python3.7 -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/ns/sj62hbw56cv68873x8_ck7gh0000gn/T/pip-install-vjn6m8ro/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/ns/sj62hbw56cv68873x8_ck7gh0000gn/T/pip-record-bp84him0/install-record.txt --single-version-externally-managed --compile --install-headers /Users/zhaokun/Documents/Python/www/venv/django_site/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,12,'final',0) -D__version__=1.3.12 -I/usr/local/opt/mysql@5.7/include/mysql -I/usr/local/Cellar/python/3.7.3/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:252:6: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
s = PyUnicode_AsUTF8(item);
^ ~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:282:6: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
s = PyUnicode_AsUTF8(item);
^ ~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:571:3: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
_stringsuck(ca, value, ssl);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:560:16: note: expanded from macro '_stringsuck'
if(t){d=PyUnicode_AsUTF8(t);ssl_keepref[n_ssl_keepref++]=t;}\
^~~~~~~~~~~~~~~~~~~~
_mysql.c:572:3: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
_stringsuck(capath, value, ssl);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:560:16: note: expanded from macro '_stringsuck'
if(t){d=PyUnicode_AsUTF8(t);ssl_keepref[n_ssl_keepref++]=t;}\
^~~~~~~~~~~~~~~~~~~~
_mysql.c:573:3: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
_stringsuck(cert, value, ssl);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:560:16: note: expanded from macro '_stringsuck'
if(t){d=PyUnicode_AsUTF8(t);ssl_keepref[n_ssl_keepref++]=t;}\
^~~~~~~~~~~~~~~~~~~~
_mysql.c:574:3: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
_stringsuck(key, value, ssl);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:560:16: note: expanded from macro '_stringsuck'
if(t){d=PyUnicode_AsUTF8(t);ssl_keepref[n_ssl_keepref++]=t;}\
^~~~~~~~~~~~~~~~~~~~
_mysql.c:575:3: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
_stringsuck(cipher, value, ssl);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:560:16: note: expanded from macro '_stringsuck'
if(t){d=PyUnicode_AsUTF8(t);ssl_keepref[n_ssl_keepref++]=t;}\
^~~~~~~~~~~~~~~~~~~~
_mysql.c:2589: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/opt/mysql@5.7/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/zhaokun/Documents/Python/www/venv/django_site/bin/python3.7 -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/ns/sj62hbw56cv68873x8_ck7gh0000gn/T/pip-install-vjn6m8ro/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/ns/sj62hbw56cv68873x8_ck7gh0000gn/T/pip-record-bp84him0/install-record.txt --single-version-externally-managed --compile --install-headers /Users/zhaokun/Documents/Python/www/venv/django_site/bin/../include/site/python3.7/mysqlclient" failed with error code 1 in /private/var/folders/ns/sj62hbw56cv68873x8_ck7gh0000gn/T/pip-install-vjn6m8ro/mysqlclient/
根据错误消息,我尝试运行clang -v
并获取以下信息:
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
我看到了很多关于堆栈溢出的问题,并观看了它们,但是它们无法解决我的问题,我试图运行xcode-select install
,并安装另一个版本的mysqlclient,但均失败了。
我也用谷歌搜索,但也不适合我。
现在我真的不知道发生了什么以及如何解决它,
答案 0 :(得分:1)
LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysqlclient
因为openssl是依赖项,并且此语句设置了它所需的库的路径。 (只有在已安装openssl的情况下,它才有效。)
答案 1 :(得分:0)
问题在这里:
8 warnings generated.
*this line->* clang -bundle -undefined dynamic_lookup build/temp.macosx-10.14-x86_64-3.7/_mysql.o -L/usr/local/opt/mysql@5.7/lib -lmysqlclient *here ->* -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
----------------------------------------
现在我无法弄清-lssl
是什么或为什么是问题,但是我认为您需要安装lssl
库:ld: library not found for -lssl
。