I'm new to MongoDB, but comfortable with Python. I installed MongoDB with
brew install mongodb
then ran
mkdir -p /data/db
then
sudo chown -R `id -un` /data/db
I installed mongoengine
with
conda install -c conda-forge mongoengine
Then trying to follow the simple example at http://docs.mongoengine.org/tutorial.html, I ran made test.py
that looks like this:
from mongoengine import *
connect('mongoengine-test')
class User(Document):
email = StringField(required=True)
bob = User(email='bob@gmail.com')
bob.save()
and ran it with python test.py
. I got this traceback:
Traceback (most recent call last):
File "test3.py", line 13, in <module>
bob = User(email='bob@gmail.com')
File "/Users/benlindsay/miniconda/lib/python3.6/site-packages/mongoengine/base/document.py", line 44, in __init__
self._initialised = False
File "/Users/benlindsay/miniconda/lib/python3.6/site-packages/mongoengine/base/document.py", line 169, in __setattr__
self._is_document and
AttributeError: 'User' object has no attribute '_is_document'
and looking up these errors online is giving me nothing.
I'm able to run mongo
manually by first starting up mongod
in one terminal, then running mongo
in another. Using that method, all the commands I see in pure MongoDB tutorials seem to be available, but the simple python example breaks every time.
Any ideas of what is going on?