无法在macOS上安装flask-mysqldb

时间:2019-07-08 05:12:08

标签: mysql pip mysql-python

当我尝试安装flask-mysqldb时出现此错误

Collecting flask-mysqldb   Using cached
https://files.pythonhosted.org/packages/62/e3/955c845efe1aacf30c8e2607470544ede36aa1044f6382c809f13e014104/Flask-MySQLdb-0.2.0.tar.gz
Requirement already satisfied: Flask>=0.10 in
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages
(from flask-mysqldb) (1.0.2) Collecting mysqlclient (from
flask-mysqldb)   Using cached
https://files.pythonhosted.org/packages/f4/f1/3bb6f64ca7a429729413e6556b7ba5976df06019a5245a43d36032f1061e/mysqlclient-1.4.2.post1.tar.gz
Requirement already satisfied: Jinja2>=2.10 in
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages
(from Flask>=0.10->flask-mysqldb) (2.10) Requirement already
satisfied: itsdangerous>=0.24 in
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages
(from Flask>=0.10->flask-mysqldb) (1.1.0) Requirement already
satisfied: click>=5.1 in
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages
(from Flask>=0.10->flask-mysqldb) (7.0) Requirement already satisfied:
Werkzeug>=0.14 in
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages
(from Flask>=0.10->flask-mysqldb) (0.14.1) Requirement already
satisfied: MarkupSafe>=0.23 in
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages
(from Jinja2>=2.10->Flask>=0.10->flask-mysqldb) (1.1.1) Installing
collected packages: mysqlclient, flask-mysqldb   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/b_/wz97t8ts7dg9lnj91y61p5rh0000gn/T/pip-install-56xxcsr1/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/b_/wz97t8ts7dg9lnj91y61p5rh0000gn/T/pip-record-113i8svg/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/8.0.16/include/mysql -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/8.0.16/lib -lmysqlclient -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/b_/wz97t8ts7dg9lnj91y61p5rh0000gn/T/pip-install-56xxcsr1/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/b_/wz97t8ts7dg9lnj91y61p5rh0000gn/T/pip-record-113i8svg/install-record.txt
--single-version-externally-managed --compile" failed with error code 1 in
/private/var/folders/b_/wz97t8ts7dg9lnj91y61p5rh0000gn/T/pip-install-56xxcsr1/mysqlclient/

1 个答案:

答案 0 :(得分:0)

如果您已安装pip(如果不使用$ sudo easy_install pip),然后在终端中使用命令$conda install -c bioconda mysqlclient(考虑到您已经安装了anaconda的事实),则运行此命令$pip install flask-mysqldb 如果未安装anaconda,只需尝试$pip install flask-mysqldb,但不能确定