Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

运行 flask forge 命令报错 TypeError: required field "type_ignores" missing from Module #6

Closed
Higurashi-kagome opened this issue Oct 12, 2020 · 2 comments

Comments

@Higurashi-kagome
Copy link

python 版本:3.8

按说明文档在 powershell 上输入命令至 flask forge 时报错:

PS C:\Users\liuhao\Desktop> cd watchlist
PS C:\Users\liuhao\Desktop\watchlist> python -m venv env
PS C:\Users\liuhao\Desktop\watchlist> env\Scripts\activate
(env) PS C:\Users\liuhao\Desktop\watchlist> pip install -r requirements.txt
...
Successfully installed Click-7.0 Flask-1.1.1 Flask-Login-0.4.1 Flask-SQLAlchemy-2.4.0 Jinja2-2.10.1 MarkupSafe-1.1.1 SQLAlchemy-1.3.6 Werkzeug-0.15.4 coverage-5.1 itsdangerous-1.1.0 python-dotenv-0.10.3
(env) PS C:\Users\liuhao\Desktop\watchlist> flask forge
Traceback (most recent call last):
  File "C:\Users\liuhao\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\liuhao\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\liuhao\Desktop\watchlist\env\Scripts\flask.exe\__main__.py", line 9, in <module>
  File "c:\users\liuhao\desktop\watchlist\env\lib\site-packages\flask\cli.py", line 966, in main
    cli.main(prog_name="python -m flask" if as_module else None)
  File "c:\users\liuhao\desktop\watchlist\env\lib\site-packages\flask\cli.py", line 586, in main
    return super(FlaskGroup, self).main(*args, **kwargs)
  File "c:\users\liuhao\desktop\watchlist\env\lib\site-packages\click\core.py", line 717, in main
    rv = self.invoke(ctx)
  File "c:\users\liuhao\desktop\watchlist\env\lib\site-packages\click\core.py", line 1132, in invoke
    cmd_name, cmd, args = self.resolve_command(ctx, args)
  File "c:\users\liuhao\desktop\watchlist\env\lib\site-packages\click\core.py", line 1171, in resolve_command
    cmd = self.get_command(ctx, cmd_name)
  File "c:\users\liuhao\desktop\watchlist\env\lib\site-packages\flask\cli.py", line 542, in get_command
    rv = info.load_app().cli.get_command(ctx, name)
  File "c:\users\liuhao\desktop\watchlist\env\lib\site-packages\flask\cli.py", line 388, in load_app
    app = locate_app(self, import_name, name)
  File "c:\users\liuhao\desktop\watchlist\env\lib\site-packages\flask\cli.py", line 240, in locate_app
    __import__(module_name)
  File "C:\Users\liuhao\Desktop\watchlist\watchlist\__init__.py", line 16, in <module>
    app = Flask(__name__)
  File "c:\users\liuhao\desktop\watchlist\env\lib\site-packages\flask\app.py", line 601, in __init__
    self.add_url_rule(
  File "c:\users\liuhao\desktop\watchlist\env\lib\site-packages\flask\app.py", line 98, in wrapper_func
    return f(self, *args, **kwargs)
  File "c:\users\liuhao\desktop\watchlist\env\lib\site-packages\flask\app.py", line 1277, in add_url_rule
    self.url_map.add(rule)
  File "c:\users\liuhao\desktop\watchlist\env\lib\site-packages\werkzeug\routing.py", line 1388, in add
    rule.bind(self)
  File "c:\users\liuhao\desktop\watchlist\env\lib\site-packages\werkzeug\routing.py", line 730, in bind
    self.compile()
  File "c:\users\liuhao\desktop\watchlist\env\lib\site-packages\werkzeug\routing.py", line 794, in compile
    self._build = self._compile_builder(False).__get__(self, None)
  File "c:\users\liuhao\desktop\watchlist\env\lib\site-packages\werkzeug\routing.py", line 951, in _compile_builder
    code = compile(module, "<werkzeug routing>", "exec")
TypeError: required field "type_ignores" missing from Module

参考 TypeError: required field "type_ignores" missing from Module 解决方案了解到“是 python3.8 的版本与 werkzeug 包的冲突”所引起,然后按说明进行了更改。之后输入 flask forge 能够正常执行。

另外,不作更改的情况下使用最新的 python 3.9.0 运行程序似乎还是会报错。

@greyli
Copy link
Member

greyli commented Jan 15, 2021

这个在 Werkzeug 新版本修复了,我有时间会更新一下依赖版本,谢谢反馈。

关联 pallets/werkzeug#1551

@greyli greyli changed the title flask forge 报错 运行 flask forge 命令报错 TypeError: required field "type_ignores" missing from Module Jan 15, 2021
@greyli
Copy link
Member

greyli commented May 22, 2022

版本已更新,谢谢。

@greyli greyli closed this as completed May 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants