简体   繁体   English

Flask 日志错误:app.run (Python 3.8) 上的“TypeError findCaller() 需要 1 到 2 个位置参数,但给出了 3 个”

[英]Flask logging error: "TypeError findCaller() takes from 1 to 2 position arguments but 3 were given" on app.run (Python 3.8)

I've got a Flask application working like a charm in Python 3.7 but when I try to run it in Python 3.8, I get the following:我有一个 Flask 应用程序在 Python 3.7 中像魅力一样工作,但是当我尝试在 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

As I understand it, Flask and Werkzeug both support Python 3.8 and and so I'm confused as to why it seems as though Flask and Werkzeug seem to be causing this issue (they're both to up to date as well).据我了解,Flask 和 Werkzeug 都支持 Python 3.8,所以我很困惑为什么 Flask 和 Werkzeug 似乎导致了这个问题(它们都是最新的)。 Further, reading through the docs, the app.run method hasn't changed in recent versions (in a way that might explain this error).此外,通过阅读文档, app.run 方法在最近的版本中没有改变(以可能解释这个错误的方式)。

Has anyone else encountered this issue?有没有其他人遇到过这个问题?

A new argument called stacklevel was added in finCaller() function in Python 3.8.在 Python 3.8 的finCaller()函数中添加了一个名为stacklevel的新参数。 If you or the packages you use has rewritten the findCaller() with only two arguments.如果您或您使用的包仅用两个参数重写了findCaller() It will throw the error TypeError: findCaller() takes from 1 to 2 positional arguments but 3 were given .它会抛出错误TypeError: findCaller() takes from 1 to 2 positional arguments but 3 were given

To fix this, you will need to add the new argument to the findCaller function you have rewritten:要解决此问题,您需要将新参数添加到您重写的findCaller函数中:

def findCaller(self, stack_info=False, stacklevel=1):

If the findCaller function that being rewritten is in other packages, you can submit an RP to fix it, just like these:如果被重写的findCaller函数在其他包中,你可以提交一个 RP 来修复它,就像这样:

I've got a Flask application working like a charm in Python 3.7 but when I try to run it in Python 3.8, I get the following:在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

As I understand it, Flask and Werkzeug both support Python 3.8 and and so I'm confused as to why it seems as though Flask and Werkzeug seem to be causing this issue (they're both to up to date as well).据我了解,Flask和Werkzeug都支持Python 3.8,因此对于为何Flask和Werkzeug似乎引起此问题的原因我感到困惑(它们都是最新的)。 Further, reading through the docs, the app.run method hasn't changed in recent versions (in a way that might explain this error).此外,通过阅读文档,app.run方法在最新版本中没有更改(以可能解释此错误的方式)。

Has anyone else encountered this issue?还有其他人遇到过这个问题吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 builtins.TypeError: _findCaller() 接受 1 到 2 个位置参数,但在 django 中给出了 3 个 - builtins.TypeError: _findCaller() takes from 1 to 2 positional arguments but 3 were given in django app.run 的 Python 烧瓶错误 - Python flask error with app.run TypeError: with_column() 从 3 到 4 个位置 arguments 但给出了 5 个(python) - TypeError: with_column() takes from 3 to 4 positional arguments but 5 were given (python) Python TypeError:接受 4 个位置参数,但给出了 5 个 - Python TypeError: takes 4 positional arguments but 5 were given Python/MySQL TypeError:execute() 需要 2 到 4 个位置参数,但给出了 5 个 - Python/MySQL TypeError: execute() takes from 2 to 4 positional arguments but 5 were given 在我的第一个 flask 应用程序上,出现此错误“TypeError:books() 需要 0 个位置 arguments 但给出了 11 个”我尝试了很多但无法解决这个问题 - On my first flask app this error comes "TypeError: books() takes 0 positional arguments but 11 were given" I have tried a lot but unable to solve this flask wtform TypeError:__ init __()取1到2个位置参数,但给出了3个 - flask wtform TypeError: __init__() takes from 1 to 2 positional arguments but 3 were given Python中的继承:“ TypeError:run()不带参数(给定2个)” - Inheritance in Python: “TypeError: run() takes no arguments (2 given)” Python TypeError:衍生物_circ()接受2个位置参数,但给出了6个 - Python TypeError: derivatives_circ() takes 2 positional arguments but 6 were given TypeError:__init __()接受2个位置参数,但是给了3个Python 3? - TypeError: __init__() takes 2 positional arguments but 3 were given Python 3?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM