我打算使用Django开发个人博客。我在配置环境时遇到此问题:
~ » pip3 install mysqlclient hwangziqi@huangziqideMBP
Collecting mysqlclient
Using cached https://files.pythonhosted.org/packages/f4/f1/3bb6f64ca7a429729413e6556b7ba5976df06019a5245a43d36032f1061e/mysqlclient-1.4.2.post1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/09/s28t32055hl9z2mcffwjhq040000gn/T/pip-install-bbsgdat8/mysqlclient/setup.py", line 16, in <module>
metadata, options = get_config()
File "/private/var/folders/09/s28t32055hl9z2mcffwjhq040000gn/T/pip-install-bbsgdat8/mysqlclient/setup_posix.py", line 53, in get_config
libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
File "/private/var/folders/09/s28t32055hl9z2mcffwjhq040000gn/T/pip-install-bbsgdat8/mysqlclient/setup_posix.py", line 53, in <listcomp>
libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
File "/private/var/folders/09/s28t32055hl9z2mcffwjhq040000gn/T/pip-install-bbsgdat8/mysqlclient/setup_posix.py", line 12, in dequote
raise Exception("Wrong MySQL configuration: maybe https://bugs.mysql.com/bug.php?id=86971 ?")
Exception: Wrong MySQL configuration: maybe https://bugs.mysql.com/bug.php?id=86971 ?
所以,我尝试了https://bugs.mysql.com/bug.php?id=86971。
$ mysql_config
Usage: /usr/local/bin/mysql_config [OPTIONS]
Options:
--cflags [-I/usr/local/Cellar/mysql-connector-c/6.1.10/include ]
--cxxflags [-I/usr/local/Cellar/mysql-connector-c/6.1.10/include ]
--include [-I/usr/local/Cellar/mysql-connector-c/6.1.10/include]
--libs [-L/usr/local/Cellar/mysql-connector-c/6.1.10/lib -l ]
--libs_r [-L/usr/local/Cellar/mysql-connector-c/6.1.10/lib -l ]
--plugindir [/usr/local/Cellar/mysql-connector-c/6.1.10/lib/plugin]
--socket [/tmp/mysql.sock]
--port [0]
--version [6.1.10]
--variable=VAR VAR is one of:
pkgincludedir [/usr/local/Cellar/mysql-connector-c/6.1.10/include]
pkglibdir [/usr/local/Cellar/mysql-connector-c/6.1.10/lib]
plugindir [/usr/local/Cellar/mysql-connector-c/6.1.10/lib/plugin]
`--libs` and `--libs_r` should have ` -lmysqlclient -lssl -lcrypto`, but it only have `-l`.
现在:
» pip3 install mysqlclient hwangziqi@huangziqideMBP
Collecting mysqlclient
Using cached https://files.pythonhosted.org/packages/f4/f1/3bb6f64ca7a429729413e6556b7ba5976df06019a5245a43d36032f1061e/mysqlclient-1.4.2.post1.tar.gz
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error
Complete output from command /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/09/s28t32055hl9z2mcffwjhq040000gn/T/pip-install-85s5jozc/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/09/s28t32055hl9z2mcffwjhq040000gn/T/pip-record-x9p5inkf/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-3.7
creating build/lib.macosx-10.9-x86_64-3.7/MySQLdb
copying MySQLdb/__init__.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb
copying MySQLdb/_exceptions.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb
copying MySQLdb/compat.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb
copying MySQLdb/connections.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb
copying MySQLdb/converters.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb
copying MySQLdb/cursors.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb
copying MySQLdb/release.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb
copying MySQLdb/times.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb
creating build/lib.macosx-10.9-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb/constants
running build_ext
building 'MySQLdb._mysql' extension
creating build/temp.macosx-10.9-x86_64-3.7
creating build/temp.macosx-10.9-x86_64-3.7/MySQLdb
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -Dversion_info=(1,4,2,'post',1) -D__version__=1.4.2.post1 -I/usr/local/Cellar/mysql-connector-c/6.1.11/include -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c MySQLdb/_mysql.c -o build/temp.macosx-10.9-x86_64-3.7/MySQLdb/_mysql.o
gcc -bundle -undefined dynamic_lookup -arch x86_64 -g build/temp.macosx-10.9-x86_64-3.7/MySQLdb/_mysql.o -L/usr/local/Cellar/mysql-connector-c/6.1.11/lib -lssl -lcrypto -o build/lib.macosx-10.9-x86_64-3.7/MySQLdb/_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 'gcc' failed with exit status 1
----------------------------------------
Command "/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/09/s28t32055hl9z2mcffwjhq040000gn/T/pip-install-85s5jozc/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/09/s28t32055hl9z2mcffwjhq040000gn/T/pip-record-x9p5inkf/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/09/s28t32055hl9z2mcffwjhq040000gn/T/pip-install-85s5jozc/mysqlclient/
我试图通过brew重新安装openssl和mysql-connector-c,但是没有用。我的英语不好,希望您能理解。太糊涂了。