无法安装flask-mysqldb模块

时间:2019-09-26 14:13:05

标签: mysql python-3.x flask cmd flask-mysql

pip install flask-mysqldb

  

C:\ Users \ prince> pip安装flask-mysqldb收集flask-mysqldb
  使用缓存   https://files.pythonhosted.org/packages/62/e3/955c845efe1aacf30c8e2607470544ede36aa1044f6382c809f13e014104/Flask-MySQLdb-0.2.0.tar.gz   已满足要求:烧瓶> = 0.10英寸   c:\ users \ prince \ appdata \ local \ programs \ python \ python37-32 \ lib \ site-packages   (来自flask-mysqldb)(1.1.1)收集mysqlclient(来自   flask-mysqldb)使用缓存   https://files.pythonhosted.org/packages/4d/38/c5f8bac9c50f3042c8f05615f84206f77f03db79781db841898fde1bb284/mysqlclient-1.4.4.tar.gz   已经满足的要求:Werkzeug> = 0.15 in   c:\ users \ prince \ appdata \ local \ programs \ python \ python37-32 \ lib \ site-packages   (来自Flask> = 0.10-> flask-mysqldb)(0.16.0)已经有要求   满意:Jinja2> = 2.10.1 in   c:\ users \ prince \ appdata \ local \ programs \ python \ python37-32 \ lib \ site-packages   (来自Flask> = 0.10-> flask-mysqldb)(2.10.1)已有要求   满意:其危险> = 0.24 in   c:\ users \ prince \ appdata \ local \ programs \ python \ python37-32 \ lib \ site-packages   (来自Flask> = 0.10-> flask-mysqldb)(1.1.0)已经有要求   满意:点击> = 5.1 in   c:\ users \ prince \ appdata \ local \ programs \ python \ python37-32 \ lib \ site-packages   (来自Flask> = 0.10-> flask-mysqldb)(7.0)已经满足要求:   MarkupSafe> = 0.23在   c:\ users \ prince \ appdata \ local \ programs \ python \ python37-32 \ lib \ site-packages   (来自Jinja2> = 2.10.1-> Flask> = 0.10-> flask-mysqldb)(1.1.1)安装   收集的软件包:mysqlclient,flask-mysqldb正在运行setup.py   为mysqlclient安装...错误       错误:命令错误,退出状态为1:        命令:“ c:\ users \ prince \ appdata \ local \ programs \ python \ python37-32 \ python.exe”   -u -c'导入sys,setuptools,令牌化; sys.argv [0] ='“'”'C:\ Users \ prince \ AppData \ Local \ Temp \ pip-install-sb1cs5ex \ mysqlclient \ setup.py'“'”';   文件 ='“'”'C:\ Users \ prince \ AppData \ Local \ Temp \ pip-install-sb1cs5ex \ mysqlclient \ setup.py'“'”'; f = getattr(tokenize,   '“”“'open'”'“,打开)(文件); code = f.read()。replace('”'“'\ r \ n'”'“',   '“'”'\\ n'“'”'); f.close(); exec(compile(code, file ,'“'”'exec'“'”')))'   安装-记录   'C:\ Users \ prince \ AppData \ Local \ Temp \ pip-record-8l4u4qqk \ install-record.txt'   -单一版本-外部管理-编译            CWD:C:\ Users \ prince \ AppData \ Local \ Temp \ pip-install-sb1cs5ex \ mysqlclient \       完整输出(30行):       运行安装       运行构建       运行build_py       创建版本       创建build \ lib.win32-3.7       创建build \ lib.win32-3.7 \ MySQLdb       复制MySQLdb__init__.py-> build \ lib.win32-3.7 \ MySQLdb       复制MySQLdb_exceptions.py-> build \ lib.win32-3.7 \ MySQLdb       复制MySQLdb \ compat.py-> build \ lib.win32-3.7 \ MySQLdb       复制MySQLdb \ connections.py-> build \ lib.win32-3.7 \ MySQLdb       复制MySQLdb \ converters.py-> build \ lib.win32-3.7 \ MySQLdb       复制MySQLdb \ cursors.py-> build \ lib.win32-3.7 \ MySQLdb       复制MySQLdb \ release.py-> build \ lib.win32-3.7 \ MySQLdb       复制MySQLdb \ times.py-> build \ lib.win32-3.7 \ MySQLdb       创建build \ lib.win32-3.7 \ MySQLdb \ constants       复制MySQLdb \ constants__init __。py-> build \ lib.win32-3.7 \ MySQLdb \ constants       复制MySQLdb \ constants \ CLIENT.py-> build \ lib.win32-3.7 \ MySQLdb \ constants       复制MySQLdb \ constants \ CR.py-> build \ lib.win32-3.7 \ MySQLdb \ constants       复制MySQLdb \ constants \ ER.py-> build \ lib.win32-3.7 \ MySQLdb \ constants       复制MySQLdb \ constants \ FIELD_TYPE.py-> build \ lib.win32-3.7 \ MySQLdb \ constants       复制MySQLdb \ constants \ FLAG.py-> build \ lib.win32-3.7 \ MySQLdb \ constants       运行build_ext       构建'MySQLdb._mysql'扩展       创建build \ temp.win32-3.7       创建build \ temp.win32-3.7 \ Release       创建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文件(x86)\ Microsoft Visual   Studio \ 2019 \ Community \ VC \ Tools \ MSVC \ 14.23.28105 \ include“” -IC:\ Program   文件(x86)\ Windows Kits \ 10 \ include \ 10.0.18362.0 \ ucrt“” -IC:\ Program   文件(x86)\ Windows Kits \ 10 \ include \ 10.0.18362.0 \ shared“” -IC:\ Program   文件(x86)\ Windows Kits \ 10 \ include \ 10.0.18362.0 \ um“” -IC:\ Program   文件(x86)\ Windows Kits \ 10 \ include \ 10.0.18362.0 \ winrt“” -IC:\ Program   文件(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):致命错误C1083:无法打开包含文件:'mysql.h':无此类文件或目录       错误:命令'C:\ Program Files(x86)\ Microsoft Visual Studio \ 2019 \ Community \ VC \ Tools \ MSVC \ 14.23.28105 \ bin \ HostX86 \ x86 \ cl.exe'   失败,退出状态为2       ----------------------------------------错误:命令错误,退出状态为1:   'c:\ users \ prince \ appdata \ local \ programs \ python \ python37-32 \ python.exe'   -u -c'导入sys,setuptools,令牌化; sys.argv [0] ='“'”'C:\ Users \ prince \ AppData \ Local \ Temp \ pip-install-sb1cs5ex \ mysqlclient \ setup.py'“'”';   文件 ='“'”'C:\ Users \ prince \ AppData \ Local \ Temp \ pip-install-sb1cs5ex \ mysqlclient \ setup.py'“'”'; f = getattr(tokenize,   '“”“'open'”'“,打开)(文件); code = f.read()。replace('”'“'\ r \ n'”'“',   '“'”'\\ n'“'”'); f.close(); exec(compile(code, file ,'“'”'exec'“'”')))'   安装-记录   'C:\ Users \ prince \ AppData \ Local \ Temp \ pip-record-8l4u4qqk \ install-record.txt'   --single-version-externally-managed --compile检查日志以获取完整的命令输出。

2 个答案:

答案 0 :(得分:1)

尝试通过以下方法安装flask-mysqldb

安装

pip install flask-mysqldb

如果出现错误或系统无法获取flask-mysqldb的wheel文件,请转到this link

您可以在其中下载轮文件,然后运行该轮文件。

如果这也不起作用,那么请先安装mysqlclient

pip install mysqlclient

,然后安装flask-mysqldb。

答案 1 :(得分:1)

它对我也不起作用,但是在单击@Suraj Virkar提供的链接后,我注意到安装命令有些不同。所以不要使用

pip install flask-mysqldb

只需使用

pip install Flask-MySQL

我不太确定为什么,但是它有效!它一定与我猜想的版本有关...哦,请注意,您必须使用

from flaskext.mysql import MySQL

将其导入您的项目中,而不是使用

from flask_mysqldb import MySQL

希望这对您有帮助...