Skip to content Skip to sidebar Skip to footer

How To Install Flask-mysqldb For Python?

I am new to Python and Python-Flask and have ran into an error. I am using Ubuntu 18.04.3 LTS and Python 2.7.15+ to build a python-flask web application. When installing flask-mysq

Solution 1:

You can not use mysqlclient‑1.4.5‑cp27‑cp27m‑win_amd64.whl as you found in other answer, because that is a wheel for Windows and you are on Linux.

The project mysqlclient, which is a dependency of flask-mysqldb, does not distribute wheels for Linux, so you have to build from source code directly (mysqlclient-1.4.5.tar.gz).

Your install likely fails due to missing build dependencies.

As the project landing page has mentioned, install the build dependencies first:

sudo apt-get install python-dev default-libmysqlclient-dev libssl-dev

Then try again to pip install --user flask-mysqldb.

Solution 2:

I followed instructions from this answer mysql_config not found when installing mysqldb python interface

Just in case I ran

sudo apt-get install mysql-server

later

sudo apt-get install libmysqlclient-dev

and finally

pip3 install flask-mysqldb

and it worked, with Ubuntu 18.04

Solution 3:

On Windows 10: pip install flask-mysqldb

This worked for me.

Post a Comment for "How To Install Flask-mysqldb For Python?"