我在Python 3.7中成功运行了一个Flask应用程序,但是当我尝试在Python 3.8中运行它时,出现以下错误:
Traceback (most recent call last):
File "index.py", line 1410, in <module>
app.run(host='0.0.0.0', port='9000', extra_files=['config'])
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/flask/app.py", line 990, in run
run_simple(host, port, self, **options)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/werkzeug/serving.py", line 1039, in run_simple
log_startup(s)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/werkzeug/serving.py", line 982, in log_startup
_log(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/werkzeug/_internal.py", line 113, in _log
getattr(_logger, type)(message.rstrip(), *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/logging/__init__.py", line 1434, in info
self._log(INFO, msg, args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/logging/__init__.py", line 1565, in _log
fn, lno, func, sinfo = self.findCaller(stack_info, stacklevel)
TypeError: findCaller() takes from 1 to 2 positional arguments but 3 were given
据我的理解,Flask和Werkzeug都支持Python 3.8,所以我很困惑为什么似乎Flask和Werkzeug会引起这个问题(它们也都是最新的版本)。此外,通过阅读文档,可以看出`app.run`方法在最近的版本中没有改变(也没有以一种可能解释这个错误的方式改变)。
有其他人遇到过这个问题吗?
findCaller()
方法吗?你是怎么调用它的? - ngShravil.pystructlog
,则会看到此消息。您至少需要19.2版本才能完全支持Python 3.8:https://www.structlog.org/en/stable/changelog.html#id10 - drs