ubuntu18桌面版 安装flask-mysqldb 编译不通过

1.本人现在用的是Ubuntu18.04桌面版。在学习flask-mysqldb过程中出现了编译错误。
2.在提问本问题之前,百度谷歌无数,奈何不合我情,特向网友求助。
3.Failed building wheel for mysqlclient
Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient, flask-mysqldb
Running setup.py install for mysqlclient ... error

Complete output from command /home/yezi/.virtualenvs/py3_flask/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-ml3efmed/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 /tmp/pip-record-0p13we0o/install-record.txt --single-version-externally-managed --compile --install-headers /home/yezi/.virtualenvs/py3_flask/include/site/python3.6/mysqlclient:
/usr/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'long_description_content_type'
  warnings.warn(msg)
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
copying _mysql_exceptions.py -> build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-3.6/MySQLdb
creating build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.linux-x86_64-3.6
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Dversion_info=(1,3,13,'final',0) -D__version__=1.3.13 -I/usr/include/mysql -I/usr/include/python3.6m -I/home/yezi/.virtualenvs/py3_flask/include/python3.6m -c _mysql.c -o build/temp.linux-x86_64-3.6/_mysql.o
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.6/_mysql.o -lmysqlclient -lpthread -lm -lrt -lssl -lcrypto -ldl -o build/lib.linux-x86_64-3.6/_mysql.cpython-36m-x86_64-linux-gnu.so
/usr/bin/x86_64-linux-gnu-ld: 找不到 -lssl
/usr/bin/x86_64-linux-gnu-ld: 找不到 -lcrypto
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  1. 在安装 flask-script,flask-wtf等,都无误。本机上装的是Mysql8.0

这所有的安装学习都是在虚拟环境中进行的。

  1. 求解决错误。
侃侃无极
浏览 654回答 1
1回答

人到中年有点甜

先安装 sudo apt-get install mysql-server libmysqld-dev 再安装 pip install flask-MySQLdb
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python