-3

pip install flask-mysqldb

C:\Users\prince>pip install 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 c:\users\prince\appdata\local\programs\python\python37-32\lib\site-packages (from flask-mysqldb) (1.1.1) Collecting mysqlclient (from flask-mysqldb) Using cached https://files.pythonhosted.org/packages/4d/38/c5f8bac9c50f3042c8f05615f84206f77f03db79781db841898fde1bb284/mysqlclient-1.4.4.tar.gz Requirement already satisfied: Werkzeug>=0.15 in c:\users\prince\appdata\local\programs\python\python37-32\lib\site-packages (from Flask>=0.10->flask-mysqldb) (0.16.0) Requirement already satisfied: Jinja2>=2.10.1 in c:\users\prince\appdata\local\programs\python\python37-32\lib\site-packages (from Flask>=0.10->flask-mysqldb) (2.10.1) Requirement already satisfied: itsdangerous>=0.24 in c:\users\prince\appdata\local\programs\python\python37-32\lib\site-packages (from Flask>=0.10->flask-mysqldb) (1.1.0) Requirement already satisfied: click>=5.1 in c:\users\prince\appdata\local\programs\python\python37-32\lib\site-packages (from Flask>=0.10->flask-mysqldb) (7.0) Requirement already satisfied: MarkupSafe>=0.23 in c:\users\prince\appdata\local\programs\python\python37-32\lib\site-packages (from Jinja2>=2.10.1->Flask>=0.10->flask-mysqldb) (1.1.1) Installing collected packages: mysqlclient, flask-mysqldb Running setup.py install for mysqlclient ... error ERROR: Command errored out with exit status 1: command: 'c:\users\prince\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\prince\AppData\Local\Temp\pip-install-sb1cs5ex\mysqlclient\setup.py'"'"'; file='"'"'C:\Users\prince\AppData\Local\Temp\pip-install-sb1cs5ex\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 'C:\Users\prince\AppData\Local\Temp\pip-record-8l4u4qqk\install-record.txt' --single-version-externally-managed --compile cwd: C:\Users\prince\AppData\Local\Temp\pip-install-sb1cs5ex\mysqlclient\ Complete output (30 lines): running install running build running build_py creating build creating build\lib.win32-3.7 creating build\lib.win32-3.7\MySQLdb copying MySQLdb__init__.py -> build\lib.win32-3.7\MySQLdb copying MySQLdb_exceptions.py -> build\lib.win32-3.7\MySQLdb copying MySQLdb\compat.py -> build\lib.win32-3.7\MySQLdb copying MySQLdb\connections.py -> build\lib.win32-3.7\MySQLdb copying MySQLdb\converters.py -> build\lib.win32-3.7\MySQLdb copying MySQLdb\cursors.py -> build\lib.win32-3.7\MySQLdb copying MySQLdb\release.py -> build\lib.win32-3.7\MySQLdb copying MySQLdb\times.py -> build\lib.win32-3.7\MySQLdb creating build\lib.win32-3.7\MySQLdb\constants copying MySQLdb\constants__init__.py -> build\lib.win32-3.7\MySQLdb\constants copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.7\MySQLdb\constants copying MySQLdb\constants\CR.py -> build\lib.win32-3.7\MySQLdb\constants copying MySQLdb\constants\ER.py -> build\lib.win32-3.7\MySQLdb\constants copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.7\MySQLdb\constants copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.7\MySQLdb\constants running build_ext building 'MySQLdb._mysql' extension creating build\temp.win32-3.7 creating build\temp.win32-3.7\Release creating build\temp.win32-3.7\Release\MySQLdb C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -Dversion_info=(1,4,4,'final',0) -D__version__=1.4.4 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include\mariadb" -Ic:\users\prince\appdata\local\programs\python\python37-32\include -Ic:\users\prince\appdata\local\programs\python\python37-32\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" /TcMySQLdb/_mysql.c /Fobuild\temp.win32-3.7\Release\MySQLdb/_mysql.obj /Zl /D_CRT_SECURE_NO_WARNINGS _mysql.c MySQLdb/_mysql.c(29): fatal error C1083: Cannot open include file: 'mysql.h': No such file or directory error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\HostX86\x86\cl.exe' failed with exit status 2 ---------------------------------------- ERROR: Command errored out with exit status 1: 'c:\users\prince\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\prince\AppData\Local\Temp\pip-install-sb1cs5ex\mysqlclient\setup.py'"'"'; file='"'"'C:\Users\prince\AppData\Local\Temp\pip-install-sb1cs5ex\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 'C:\Users\prince\AppData\Local\Temp\pip-record-8l4u4qqk\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.

johnny243
  • 304
  • 3
  • 13
Prince Patel
  • 1
  • 1
  • 2

2 Answers2

3

It didn't worked for me too, but after clicking the link provided by @Suraj Virkar, I noticed that the command for installing is a little different. So instead of using

pip install flask-mysqldb

Just use

pip install Flask-MySQL

and i'm not really sure why but it worked! it must have someting to do with the versions i guess... oh and take note that you'll have to use

from flaskext.mysql import MySQL

to import it on your project instead of using

from flask_mysqldb import MySQL

Hope this helps...

  • Those seems like different packages ... it might be a solution to the problem to change to another package but it seems to me that's not answering the question we have here. – Rafael Jan 14 '22 at 12:42
0

try to install flask-mysqldb by the following method

Installation

pip install flask-mysqldb

if you get error or system cannot fetch wheel file of flask-mysqldb, then go to this link

where you can download wheel file and then run that wheel file.

If this also not working then first install mysqlclient

pip install mysqlclient

and then install flask-mysqldb.

Suraj Virkar
  • 511
  • 1
  • 4
  • 13