Pip install flask_mysqldb getting error: ERROR: Command errored out with exit status 1:

Moemen Hussein :

I am working at the moment to make an application. I want to make a connection to my database by using flask_mysqldb. I am making my environment in Flask. But when I try to download flask_mysqldb I am getting a long weird error. I searched on the internet for this problem but didn't seem to find any solutions. Or any problems like mine. The command that I use to install flask_mysqldb is :

pip install flask_mysqldb

This is the error that i am getting:

  ERROR: Command errored out with exit status 1:
   command: 'C:\Users\Gebruiker\Envs\ticketsystem\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Gebruiker\\AppData\\Local\\Temp\\pip-install-pw1dam8u\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\Gebruiker\\AppData\\Local\\Temp\\pip-install-pw1dam8u\\mysqlclient\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\Gebruiker\AppData\Local\Temp\pip-wheel-8qolbr5n'
       cwd: C:\Users\Gebruiker\AppData\Local\Temp\pip-install-pw1dam8u\mysqlclient\
  Complete output (30 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win32-3.8
  creating build\lib.win32-3.8\MySQLdb
  copying MySQLdb\__init__.py -> build\lib.win32-3.8\MySQLdb
  copying MySQLdb\_exceptions.py -> build\lib.win32-3.8\MySQLdb
  copying MySQLdb\compat.py -> build\lib.win32-3.8\MySQLdb
  copying MySQLdb\connections.py -> build\lib.win32-3.8\MySQLdb
  copying MySQLdb\converters.py -> build\lib.win32-3.8\MySQLdb
  copying MySQLdb\cursors.py -> build\lib.win32-3.8\MySQLdb
  copying MySQLdb\release.py -> build\lib.win32-3.8\MySQLdb
  copying MySQLdb\times.py -> build\lib.win32-3.8\MySQLdb
  creating build\lib.win32-3.8\MySQLdb\constants
  copying MySQLdb\constants\__init__.py -> build\lib.win32-3.8\MySQLdb\constants
  copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.8\MySQLdb\constants
  copying MySQLdb\constants\CR.py -> build\lib.win32-3.8\MySQLdb\constants
  copying MySQLdb\constants\ER.py -> build\lib.win32-3.8\MySQLdb\constants
  copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.8\MySQLdb\constants
  copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.8\MySQLdb\constants
  running build_ext
  building 'MySQLdb._mysql' extension
  creating build\temp.win32-3.8
  creating build\temp.win32-3.8\Release
  creating build\temp.win32-3.8\Release\MySQLdb
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,4,6,'final',0) -D__version__=1.4.6 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include\mariadb" -IC:\Users\Gebruiker\Envs\ticketsystem\include -Ic:\users\gebruiker\appdata\local\programs\python\python38-32\include -Ic:\users\gebruiker\appdata\local\programs\python\python38-32\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" "-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.8\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.25.28610\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
  ----------------------------------------
  ERROR: 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
    ERROR: Command errored out with exit status 1:
     command: 'C:\Users\Gebruiker\Envs\ticketsystem\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Gebruiker\\AppData\\Local\\Temp\\pip-install-pw1dam8u\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\Gebruiker\\AppData\\Local\\Temp\\pip-install-pw1dam8u\\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\Gebruiker\AppData\Local\Temp\pip-record-5dfqjh2g\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\Gebruiker\Envs\ticketsystem\include\site\python3.8\mysqlclient'
         cwd: C:\Users\Gebruiker\AppData\Local\Temp\pip-install-pw1dam8u\mysqlclient\
    Complete output (30 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.8
    creating build\lib.win32-3.8\MySQLdb
    copying MySQLdb\__init__.py -> build\lib.win32-3.8\MySQLdb
    copying MySQLdb\_exceptions.py -> build\lib.win32-3.8\MySQLdb
    copying MySQLdb\compat.py -> build\lib.win32-3.8\MySQLdb
    copying MySQLdb\connections.py -> build\lib.win32-3.8\MySQLdb
    copying MySQLdb\converters.py -> build\lib.win32-3.8\MySQLdb
    copying MySQLdb\cursors.py -> build\lib.win32-3.8\MySQLdb
    copying MySQLdb\release.py -> build\lib.win32-3.8\MySQLdb
    copying MySQLdb\times.py -> build\lib.win32-3.8\MySQLdb
    creating build\lib.win32-3.8\MySQLdb\constants
    copying MySQLdb\constants\__init__.py -> build\lib.win32-3.8\MySQLdb\constants
    copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.8\MySQLdb\constants
    copying MySQLdb\constants\CR.py -> build\lib.win32-3.8\MySQLdb\constants
    copying MySQLdb\constants\ER.py -> build\lib.win32-3.8\MySQLdb\constants
    copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.8\MySQLdb\constants
    copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.8\MySQLdb\constants
    running build_ext
    building 'MySQLdb._mysql' extension
    creating build\temp.win32-3.8
    creating build\temp.win32-3.8\Release
    creating build\temp.win32-3.8\Release\MySQLdb
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,4,6,'final',0) -D__version__=1.4.6 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include\mariadb" -IC:\Users\Gebruiker\Envs\ticketsystem\include -Ic:\users\gebruiker\appdata\local\programs\python\python38-32\include -Ic:\users\gebruiker\appdata\local\programs\python\python38-32\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" "-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.8\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.25.28610\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\Gebruiker\Envs\ticketsystem\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Gebruiker\\AppData\\Local\\Temp\\pip-install-pw1dam8u\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\Gebruiker\\AppData\\Local\\Temp\\pip-install-pw1dam8u\\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\Gebruiker\AppData\Local\Temp\pip-record-5dfqjh2g\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\Gebruiker\Envs\ticketsystem\include\site\python3.8\mysqlclient' Check the logs for full command output.

I am on Windows 10.

swehren :

Flask_mysqldb depends on mysqlclient-python which says this about installing on Windows:

Building mysqlclient on Windows is very hard. But there are some binary wheels you can install easily.

Here's the list of wheels for the current version:

https://pypi.org/project/mysqlclient/1.4.6/#files

You can download the one that fits your platform and then install with pip install filename.whl Then you should be able to install flask_mysqldb without that error.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=402067&siteId=1