使用python 3.6,烧瓶为0.12.4
在werkzeug> = 0.15时失败,在werkzeug == 0.14.1上正常运行
以下是重现该错误所需的最少代码:
from flask import Flask, redirect
app = Flask(__name__)
@app.route("/")
def hello():
return redirect('/')
client = app.test_client()
client.get('/', follow_redirects=True)
这是回溯
Traceback (most recent call last):
File "hello.py", line 9, in <module>
client.get('/', follow_redirects=True)
File "/usr/local/lib/python3.6/site-packages/werkzeug/test.py", line 1028, in get
return self.open(*args, **kw)
File "/usr/local/lib/python3.6/site-packages/flask/testing.py", line 127, in open
follow_redirects=follow_redirects)
File "/usr/local/lib/python3.6/site-packages/werkzeug/test.py", line 1016, in open
response, new_location, environ, buffered=buffered
File "/usr/local/lib/python3.6/site-packages/werkzeug/test.py", line 947, in resolve_redirect
return self.open(builder, as_tuple=True, buffered=buffered)
File "/usr/local/lib/python3.6/site-packages/flask/testing.py", line 122, in open
builder = make_test_environ_builder(self.application, *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/flask/testing.py", line 29, in make_test_environ_builder
url = url_parse(path)
File "/usr/local/lib/python3.6/site-packages/werkzeug/urls.py", line 457, in url_parse
i = url.find(s(":"))
AttributeError: 'EnvironBuilder' object has no attribute 'find'
答案 0 :(得分:1)
您必须升级Flask或降级Werkzeug。 1.0之前的Flask版本不支持Werkzeug> 0.14