Error importing pymongo in my django app
django, mongodb, pymongo
Solution
This error happened to me after `pip install` (in virtualenv) both `pymongo` and `bson`.
Uninstall `pymongo` and `bson` and install again just `pymongo` - it ships with its own version of `bson` not compatible with the `bson` package.
https://stackoverflow.com/a/12983651/196206
Problem
I'm trying to insert documents into mongodb from django and I'm getting an error on the import statement for pymongo. I don't have a duplicate file anywhere called pymongo and I'm pretty sure my virtualenv is set up correctly. ``` (django-sample-app)ubuntu@django (884) ~ $ python Python 2.7.3 (default, Aug 1 2012, 05:14:39) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import bson >>> import pymongo Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/ubuntu/.virtualenvs/django-sample-app/local/lib/python2.7/site-packages/pymongo/__init__.py", line 80, in <module> from pymongo.connection import Connection File "/home/ubuntu/.virtualenvs/django-sample-app/local/lib/python2.7/site-packages/pymongo/connection.py", line 39, in <module> from pymongo.mongo_client import MongoClient File "/home/ubuntu/.virtualenvs/django-sample-app/local/lib/python2.7/site-packages/pymongo/mongo_client.py", line 45, in <module> from pymongo import (auth, File "/home/ubuntu/.virtualenvs/django-sample-app/local/lib/python2.7/site-packages/pymongo/database.py", line 22, in <module> from pymongo.collection import Collection File "/home/ubuntu/.virtualenvs/django-sample-app/local/lib/python2.7/site-packages/pymongo/collection.py", line 25, in <module> from pymongo.cursor import Cursor File "/home/ubuntu/.virtualenvs/django-sample-app/local/lib/python2.7/site-packages/pymongo/cursor.py", line 19, in <module> from bson import RE_TYPE ImportError: cannot import name RE_TYPE ```