ImportError: No module named objectid

后端 未结 4 1115
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-03 17:57

I have currently django-mongodb-engine 0.4.0 version installed on my Mac OS X 10.6.8 and weirdly encountered an interesting error while importing the \'compiler\' module:

相关标签:
4条回答
  • 2020-12-03 18:09

    I'm on Python3 (in 2017) and found that the following works:

    from pymongo import MongoClient
    from bson import ObjectId
    
    0 讨论(0)
  • 2020-12-03 18:14

    I tried to install bson with pip directly. Uninstall, and install pymongo instead and the error didnt reappear.

    0 讨论(0)
  • Looks like they're already aware (see this pull request), but no one's created a pull request against the develop branch yet. You could try fixing that and submit a new pull request.

    0 讨论(0)
  • 2020-12-03 18:31

    I've ran into something similar, for me the problem was this line:

    from pymongo.objectid import ObjectId
    

    The call seems to work in versions of PyMongo < 2.2

    In pymongo 2.2 the call to import objectid is:

    from bson.objectid import ObjectId
    
    0 讨论(0)
提交回复
热议问题