问题
TypeError: ‘Collection’ object is not callable. If you meant to call the ‘collection_names’ method on a ‘Database’ object it is failing because no such method exists.
解决方法
-
查看pymongo 方法引用
以下方法在pymongo 3.x 之后就不再支持:- save()
- insert()
- update()
- remove()
- find_and_modify()
- ensure_index()
需要换成:
* insert_one() / insert_many()
* update_one() / update_many()
* delete_one() / delete_many()
- 查看celery 和 pymongo 的版本
但是在我的问题中并没有使用这些被弃用的方法
然后看了下报错位置是在celery5.2.7相关依赖里触发,所以怀疑是版本不兼容,于是把 pymongo4.3.2 降级为3.12.0
就好了