一:python3 pip3 install mysqlclient mac电脑安装错误
主要报错如下:
Failed to build mysqlclient
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error
Complete output from command /Users/damon/damontest/e_commerce_django/backend_store/storevenv/bin/python3 -u -c "import setuptools, tokenize;__file__='/private/var/folders/h7/k1x3xbbx55n_nppmw3k_4n8h0000gn/T/pip-build-kijy124c/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 /var/folders/h7/k1x3xbbx55n_nppmw3k_4n8h0000gn/T/pip-o14gjln0-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/damon/damontest/e_commerce_django/backend_store/storevenv/include/site/python3.6/mysqlclient:
running install
running build
running build_py
creating build
creating 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/_exceptions.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
running build_ext
building 'MySQLdb._mysql' extension
creating build/temp.macosx-10.6-intel-3.6
creating build/temp.macosx-10.6-intel-3.6/MySQLdb
/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,4,6,'final',0) -D__version__=1.4.6 -I/usr/local/opt/mysql@5.7/include/mysql -I/Users/damon/damontest/e_commerce_django/backend_store/storevenv/include -I/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c MySQLdb/_mysql.c -o build/temp.macosx-10.6-intel-3.6/MySQLdb/_mysql.o
/usr/bin/clang -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -g -L/usr/local/opt/openssl/lib build/temp.macosx-10.6-intel-3.6/MySQLdb/_mysql.o -L/usr/local/opt/mysql@5.7/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.6-intel-3.6/MySQLdb/_mysql.cpython-36m-darwin.so
ld: warning: directory not found for option '-L/usr/local/opt/openssl/lib'
ld: warning: directory not found for option '-L/usr/local/opt/openssl/lib'
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command '/usr/bin/clang' failed with exit status 1
----------------------------------------
Command "/Users/damon/damontest/e_commerce_django/backend_store/storevenv/bin/python3 -u -c "import setuptools, tokenize;__file__='/private/var/folders/h7/k1x3xbbx55n_nppmw3k_4n8h0000gn/T/pip-build-kijy124c/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 /var/folders/h7/k1x3xbbx55n_nppmw3k_4n8h0000gn/T/pip-o14gjln0-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/damon/damontest/e_commerce_django/backend_store/storevenv/include/site/python3.6/mysqlclient" failed with error code 1 in /private/var/folders/h7/k1x3xbbx55n_nppmw3k_4n8h0000gn/T/pip-build-kijy124c/mysqlclient/
在这里深情提示一下,一定要看一下你的openssl安装的目录,我是用brew安装的,所以我的目录是:/usr/local/opt/openssl@1.1
,大佬请注意那个@1.1
,我真是个SB一开始没注意。
然后我根据网上的解决办法
LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysqlclient
我换成我的:
LDFLAGS=-L/usr/local/opt/openssl@1.1/lib pip install mysqlclient
然后就成了,搞了我一天,我真是ZZ