Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import Error : ImportError: cannot import name 'abc' from 'bson.py3compat'

Tags:

python

How can i solve this error. It will generate while running program.

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)
like image 851
Jugal Adhyaru Avatar asked Feb 10 '20 11:02

Jugal Adhyaru


1 Answers

That's most likely due to version mismatches.

This worked for me:

pip uninstall bson
pip uninstall pymongo
pip install pymongo
like image 125
P-S Avatar answered Nov 12 '22 05:11

P-S