我想使用Flask-MongoEngine正常工作,但是我试图使调试工具栏正常工作,并且当我遵循文档时,得到如下所示的回溯。我能够正常运行烧瓶调试工具栏,但是由于我使用MongoDB作为数据库,因此我试图将烧瓶调试工具栏与MongoDB结合使用。我知道以下行是此回溯的原因。
app.config['DEBUG_TB_PANELS'] = ['flask_mongoengine.panels.MongoDebugPanel']
from flask import Flask
from flask_debugtoolbar import DebugToolbarExtension
app = Flask(__name__)
app.config['DEBUG_TB_PANELS'] = ['flask_mongoengine.panels.MongoDebugPanel']
db = MongoEngine(app)
toolbar = DebugToolbarExtension(app)
app.config['DEBUG_TB_PANELS'] = ['flask_mongoengine.panels.MongoDebugPanel']
#traceback
Traceback (most recent call last):
File "app.py", line 27, in <module>
toolbar = DebugToolbarExtension(app)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask_debugtoolbar/__init__.py", line 58, in __init__
self.init_app(app)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask_debugtoolbar/__init__.py", line 72, in init_app
DebugToolbar.load_panels(app)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask_debugtoolbar/toolbar.py", line 50, in load_panels
for panel_class in cls._iter_panels(app):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask_debugtoolbar/toolbar.py", line 57, in _iter_panels
panel_class = cls._import_panel(app, panel_path)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask_debugtoolbar/toolbar.py", line 71, in _import_panel
panel_class = import_string(path)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/werkzeug/utils.py", line 418, in import_string
__import__(import_name)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask_mongoengine/panels.py", line 5, in <module>
from flask_mongoengine import operation_tracker
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask_mongoengine/operation_tracker.py", line 26, in <module>
'_unpack_response': pymongo.helpers._unpack_response,
AttributeError: module 'pymongo.helpers' has no attribute '_unpack_response'
答案 0 :(得分:0)
自pymongo 3.6.0起,_unpack_respone
方法似乎已消失或被重写。
一种解决方法是安装pymongo<3.6.0