Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: No module named objectid

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:

>> from django_mongodb_engine import compiler

and I got the following error:

ImportError Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django_extensions/management/commands/shell_plus.pyc in <module>()
----> 1 from django_mongodb_engine import compiler

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django_mongodb_engine/compiler.pyc in <module>()
      15 from pymongo.errors import PyMongoError
      16 from pymongo import ASCENDING, DESCENDING
 ---> 17 from pymongo.objectid import ObjectId, InvalidId
      18 
      19 from djangotoolbox.db.basecompiler import NonrelQuery, NonrelCompiler, \

ImportError: No module named objectid

I installed the package via pip command and all the dependencies like pymongo, djangotoolbox have been installed along with it. The pip command I'd used is this:

>> sudo env ARCHFLAGS='-arch i386 -arch x86_64' pip install --upgrade  django-mongodb-engine

The current versions of the related packages are:

>> pip freeze | grep mongo
django-mongodb-engine==0.4.0
pymongo==2.2

I suspect the django_mongodb_engine package is broken because ObjectId is not imported inside pymongo anymore. Instead, it belongs to bson module.

What are your suggestions to fix this problem? Should I clone the django-mongodb-engine project and fix on github?

like image 570
Ozgur Vatansever Avatar asked May 14 '12 08:05

Ozgur Vatansever


2 Answers

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

like image 166
David Avatar answered Oct 02 '22 18:10

David


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.

like image 27
Dominic Rodger Avatar answered Oct 02 '22 19:10

Dominic Rodger