Pip install flask_mysqldb获取错误:错误:命令出错,退出状态为1:



我现在正在制作一个应用程序。我想使用flask_mysqldb连接到我的数据库。我正在佛罗里达州创造我的环境。但当我尝试下载flask_mysqldb时,我遇到了一个奇怪的错误。我在网上搜索这个问题,但似乎没有找到任何解决方案。或者任何像我这样的问题。我用来安装flask_mysqldb的命令是:

pip install flask_mysqldb

这是我得到的错误:

ERROR: Command errored out with exit status 1:
command: 'C:UsersGebruikerEnvsticketsystemScriptspython.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('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:UsersGebruikerAppDataLocalTemppip-wheel-8qolbr5n'
cwd: C:UsersGebruikerAppDataLocalTemppip-install-pw1dam8umysqlclient
Complete output (30 lines):
running bdist_wheel
running build
running build_py
creating build
creating buildlib.win32-3.8
creating buildlib.win32-3.8MySQLdb
copying MySQLdb__init__.py -> buildlib.win32-3.8MySQLdb
copying MySQLdb_exceptions.py -> buildlib.win32-3.8MySQLdb
copying MySQLdbcompat.py -> buildlib.win32-3.8MySQLdb
copying MySQLdbconnections.py -> buildlib.win32-3.8MySQLdb
copying MySQLdbconverters.py -> buildlib.win32-3.8MySQLdb
copying MySQLdbcursors.py -> buildlib.win32-3.8MySQLdb
copying MySQLdbrelease.py -> buildlib.win32-3.8MySQLdb
copying MySQLdbtimes.py -> buildlib.win32-3.8MySQLdb
creating buildlib.win32-3.8MySQLdbconstants
copying MySQLdbconstants__init__.py -> buildlib.win32-3.8MySQLdbconstants
copying MySQLdbconstantsCLIENT.py -> buildlib.win32-3.8MySQLdbconstants
copying MySQLdbconstantsCR.py -> buildlib.win32-3.8MySQLdbconstants
copying MySQLdbconstantsER.py -> buildlib.win32-3.8MySQLdbconstants
copying MySQLdbconstantsFIELD_TYPE.py -> buildlib.win32-3.8MySQLdbconstants
copying MySQLdbconstantsFLAG.py -> buildlib.win32-3.8MySQLdbconstants
running build_ext
building 'MySQLdb._mysql' extension
creating buildtemp.win32-3.8
creating buildtemp.win32-3.8Release
creating buildtemp.win32-3.8ReleaseMySQLdb
C:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.25.28610binHostX86x86cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,4,6,'final',0) -D__version__=1.4.6 "-IC:Program Files (x86)MySQLMySQL Connector C 6.1includemariadb" -IC:UsersGebruikerEnvsticketsysteminclude -Ic:usersgebruikerappdatalocalprogramspythonpython38-32include -Ic:usersgebruikerappdatalocalprogramspythonpython38-32include "-IC:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.25.28610ATLMFCinclude" "-IC:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.25.28610include" "-IC:Program Files (x86)Windows KitsNETFXSDK4.8includeum" "-IC:Program Files (x86)Windows Kits10include10.0.18362.0ucrt" "-IC:Program Files (x86)Windows Kits10include10.0.18362.0shared" "-IC:Program Files (x86)Windows Kits10include10.0.18362.0um" "-IC:Program Files (x86)Windows Kits10include10.0.18362.0winrt" "-IC:Program Files (x86)Windows Kits10include10.0.18362.0cppwinrt" /TcMySQLdb/_mysql.c /Fobuildtemp.win32-3.8ReleaseMySQLdb/_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:UsersGebruikerEnvsticketsystemScriptspython.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('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:UsersGebruikerAppDataLocalTemppip-record-5dfqjh2ginstall-record.txt' --single-version-externally-managed --compile --install-headers 'C:UsersGebruikerEnvsticketsystemincludesitepython3.8mysqlclient'
cwd: C:UsersGebruikerAppDataLocalTemppip-install-pw1dam8umysqlclient
Complete output (30 lines):
running install
running build
running build_py
creating build
creating buildlib.win32-3.8
creating buildlib.win32-3.8MySQLdb
copying MySQLdb__init__.py -> buildlib.win32-3.8MySQLdb
copying MySQLdb_exceptions.py -> buildlib.win32-3.8MySQLdb
copying MySQLdbcompat.py -> buildlib.win32-3.8MySQLdb
copying MySQLdbconnections.py -> buildlib.win32-3.8MySQLdb
copying MySQLdbconverters.py -> buildlib.win32-3.8MySQLdb
copying MySQLdbcursors.py -> buildlib.win32-3.8MySQLdb
copying MySQLdbrelease.py -> buildlib.win32-3.8MySQLdb
copying MySQLdbtimes.py -> buildlib.win32-3.8MySQLdb
creating buildlib.win32-3.8MySQLdbconstants
copying MySQLdbconstants__init__.py -> buildlib.win32-3.8MySQLdbconstants
copying MySQLdbconstantsCLIENT.py -> buildlib.win32-3.8MySQLdbconstants
copying MySQLdbconstantsCR.py -> buildlib.win32-3.8MySQLdbconstants
copying MySQLdbconstantsER.py -> buildlib.win32-3.8MySQLdbconstants
copying MySQLdbconstantsFIELD_TYPE.py -> buildlib.win32-3.8MySQLdbconstants
copying MySQLdbconstantsFLAG.py -> buildlib.win32-3.8MySQLdbconstants
running build_ext
building 'MySQLdb._mysql' extension
creating buildtemp.win32-3.8
creating buildtemp.win32-3.8Release
creating buildtemp.win32-3.8ReleaseMySQLdb
C:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.25.28610binHostX86x86cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,4,6,'final',0) -D__version__=1.4.6 "-IC:Program Files (x86)MySQLMySQL Connector C 6.1includemariadb" -IC:UsersGebruikerEnvsticketsysteminclude -Ic:usersgebruikerappdatalocalprogramspythonpython38-32include -Ic:usersgebruikerappdatalocalprogramspythonpython38-32include "-IC:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.25.28610ATLMFCinclude" "-IC:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.25.28610include" "-IC:Program Files (x86)Windows KitsNETFXSDK4.8includeum" "-IC:Program Files (x86)Windows Kits10include10.0.18362.0ucrt" "-IC:Program Files (x86)Windows Kits10include10.0.18362.0shared" "-IC:Program Files (x86)Windows Kits10include10.0.18362.0um" "-IC:Program Files (x86)Windows Kits10include10.0.18362.0winrt" "-IC:Program Files (x86)Windows Kits10include10.0.18362.0cppwinrt" /TcMySQLdb/_mysql.c /Fobuildtemp.win32-3.8ReleaseMySQLdb/_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:UsersGebruikerEnvsticketsystemScriptspython.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('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:UsersGebruikerAppDataLocalTemppip-record-5dfqjh2ginstall-record.txt' --single-version-externally-managed --compile --install-headers 'C:UsersGebruikerEnvsticketsystemincludesitepython3.8mysqlclient' Check the logs for full command output.

我使用的是Windows 10。

Flask_mysqldb依赖于mysqlclient python,该python说明了在Windows:上安装

在Windows上构建mysqlclient非常困难。但也有一些二进制轮子,你可以很容易地安装。

以下是当前版本的轮子列表:

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

你可以下载适合你的平台的,然后用pip install filename.whl安装。然后你应该可以安装flask_mysqldb而不会出现错误。

最新更新