0
点赞
收藏
分享

微信扫一扫

‘Collection‘ object is not callable. If you meant to call the ‘authenticate‘ method on a ‘Database‘

[BUG已解决]链接数据库MongoDB报错:

报错模板如下:

'Collection' object is not callable. If you meant to call the 'authenticate' method on a 'Database' object it is failing because no such method exists. 在这里插入图片描述

背景

在使用前后端分离项目,后端使用flask链接数据库MongoDB,之前跑的好好的,过了一段时间发现无法运行,显示数据库连接报错。 数据库已经部署到服务器!

解决方案:

出现下面这个bug,大多数是因为我们模块版本问题,应该是版本太高,不能支持之前的语法。

from pymongo import MongoClient

'Collection' object is not callable. If you meant to call the 'authenticate' method on a 'Database' object it is failing because no such method exists.

回退版本:

现在我的pymongo版本为4.4.1 我进入我的服务器上,发现版本为:3.9.0 在这里插入图片描述 那么我回退到3.9.0,,问题即可被解决! 在这里插入图片描述 项目成功启动,BUG解决: 在这里插入图片描述 'Collection' object is not callable. If you meant to call the 'authenticate' method on a 'Database' object it is failing because no such method exists.

举报
0 条评论