Ubuntu18 Desktop version installation flask-mysqldb compilation failed

1. I am using the Ubuntu18.04 desktop version now. A compilation error occurred during learning flask-mysqldb.
2. Before asking this question, Baidu Google numerous, but not my feelings, specially to ask netizens for help.
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. when installing flask-script,flask-wtf, etc., all are correct. Mysql8.0
is installed on this machine.

all of this installation learning is done in a virtual environment.

  1. seek to resolve the error.
Jul.16,2021

 
sudo apt-get install mysql-server libmysqld-dev

pip install flask-MySQLdb
Menu