jhao104 / proxy_pool

Python ProxyPool for web spider
https://jhao104.github.io/proxy_pool/
MIT License
21.34k stars 5.14k forks source link

Python 3.8需要升级Werkzeug依赖,否则提示type_ignores错误 #473

Open yilu1015 opened 4 years ago

yilu1015 commented 4 years ago

使用Python 3.8, Werkzeug 0.15.3时会提示如下错误:

Traceback (most recent call last):
  File "proxyPool.py", line 19, in <module>
    from api.proxyApi import runFlask
  File "/home/louis/wenshu/proxy_pool/api/proxyApi.py", line 27, in <module>
    app = Flask(__name__)
  File "/home/louis/wenshu/wenshu/lib/python3.8/site-packages/flask/app.py", line 556, in __init__
    self.add_url_rule(
  File "/home/louis/wenshu/wenshu/lib/python3.8/site-packages/flask/app.py", line 64, in wrapper_func
    return f(self, *args, **kwargs)
  File "/home/louis/wenshu/wenshu/lib/python3.8/site-packages/flask/app.py", line 1214, in add_url_rule
    self.url_map.add(rule)
  File "/home/louis/wenshu/wenshu/lib/python3.8/site-packages/werkzeug/routing.py", line 1386, in add
    rule.bind(self)
  File "/home/louis/wenshu/wenshu/lib/python3.8/site-packages/werkzeug/routing.py", line 730, in bind
    self.compile()
  File "/home/louis/wenshu/wenshu/lib/python3.8/site-packages/werkzeug/routing.py", line 794, in compile
    self._build = self._compile_builder(False).__get__(self, None)
  File "/home/louis/wenshu/wenshu/lib/python3.8/site-packages/werkzeug/routing.py", line 945, in _compile_builder
    code = compile(module, "<werkzeug routing>", "exec")
TypeError: required field "type_ignores" missing from Module

经查询,此问题在许多使用Flask的程序中都有,解决方法为升级Werkzeug至 0.15.5 或更高。(我尝试了pip install Werkzeug==0.16.0),成功解决。

可参见: https://github.com/pjialin/py12306/issues/355 https://github.com/WhaleShark-Team/cobra/issues/1382 等。

建议修改requirements.txt中版本要求。

mkdir700 commented 3 years ago

谢谢!

GentleTyphoon commented 3 years ago

感谢