导入错误:ImportError:无法从“ bson.py3compat”导入名称“ abc”

时间:2020-02-10 11:50:27

标签: python

我该如何解决此错误。它将在运行程序时生成。

from bson import ObjectId
class JSONEncoder(json.JSONEncoder):
    def default(self, o):
        if isinstance(o, ObjectId):
            return str(o)
        return json.JSONEncoder.default(self, o)

1 个答案:

答案 0 :(得分:21)

这很可能是由于版本不匹配所致。

这对我有用:

pip uninstall bson
pip uninstall pymongo
pip install pymongo
相关问题