Closed GroverChouT closed 2 years ago
@mseimys Thanks
No problem. Anyway, I wouldn't close this issue just yet - problem is still there, i haven't got enough skills yet to fix it :)
With the progress of refer to: #935 I find it.
Got the same problem, i guess Closed is not meant to, as the issue is still present.
Got the same problem +1
+1
+1
It is fixed in master, so just use mongoengine master (and wait for next release) or use pymongo==2.8. Adding +1 will not help here :)
I already got it working with 2.8 :P so its not just the matter of +1 ;) @MRigal
+1, please how can I downgrade?
@lukaspetr Add pymongo==2.8.1
in your requirements.txt
@hamzawaqas-10p thank you. It was also necessary to change the setting to install_requires=['pymongo==2.8.1'],
in mongoengine's setup.py
Will this problem be fixed in the next version?
Since it is in master, for sure :-)
2015-06-04 13:49 GMT+02:00 Petr Lukas notifications@github.com:
Will this problem be fixed in the next version?
— Reply to this email directly or view it on GitHub https://github.com/MongoEngine/mongoengine/issues/950#issuecomment-108857109 .
@MRigal thank you for the piece of information!
Looks like @MRigal fixed it, thank you!
+1
+1
2.8 it workd!
+1
+1
pymongo 3.1 is not work.
now, i have to use pymongo 2.8
@hhstore I think it's released now. Which version of mongoengine do you have?
Still present in MongoDB shell version: 3.2.5.
Got pymongo 3.2.2, mongoengine 0.9, got this bug.
Is this problem solved yet? I want to upgrade my backend to python3.5 and pymongo 3.0.3 is not catching up with you guys for this error. pymongo 2.8 is supported only to python 3.4. Which forces me down to python 3.4.
I am using django 1.11 , python 3.5, mongoengine 0.13.0, pymongo-3.4.0 same error
+1 mac
OS X High Sierra, mongoengine 0.15.0, pymongo 3.3.2 same error, if it helps get this resolved sooner.
Trying to use mongonengine with django, I have to use mongoengine 0.9.0. So now I also have to downgrade pymongo to 2.8. Not good..
I am facing this issue as well. Any solution? Downgrading to 2.8 did not solve the issue. Instead, it created another issue.
@ishantanu Can you clarify the problem? You only observe this with dango, right? Can you provide a code snippet that shows the issue?
@bagerard I am observing it with something built with Flask and python. So, after downgrading pymongo to 2.8.1, I am seeing this issue:
Traceback (most recent call last):
File "toolbox/collect-tweets.py", line 10, in <module>
from smm import models
File "/Users/shantanudeshpande/streamcrab/smm/models.py", line 2, in <module>
import mongoengine
File "/usr/local/lib/python2.7/site-packages/mongoengine/__init__.py", line 3, in <module>
from mongoengine import document
File "/usr/local/lib/python2.7/site-packages/mongoengine/document.py", line 10, in <module>
from mongoengine.base import (BaseDict, BaseDocument, BaseList,
File "/usr/local/lib/python2.7/site-packages/mongoengine/base/__init__.py", line 11, in <module>
from mongoengine.base.metaclasses import *
File "/usr/local/lib/python2.7/site-packages/mongoengine/base/metaclasses.py", line 9, in <module>
from mongoengine.queryset import (DO_NOTHING, DoesNotExist,
File "/usr/local/lib/python2.7/site-packages/mongoengine/queryset/__init__.py", line 3, in <module>
from mongoengine.queryset.manager import *
File "/usr/local/lib/python2.7/site-packages/mongoengine/queryset/manager.py", line 2, in <module>
from mongoengine.queryset.queryset import QuerySet
File "/usr/local/lib/python2.7/site-packages/mongoengine/queryset/queryset.py", line 4, in <module>
from mongoengine.queryset.base import (BaseQuerySet, CASCADE, DENY, DO_NOTHING,
File "/usr/local/lib/python2.7/site-packages/mongoengine/queryset/base.py", line 20, in <module>
from mongoengine.context_managers import set_write_concern, switch_db
File "/usr/local/lib/python2.7/site-packages/mongoengine/context_managers.py", line 2, in <module>
from pymongo.write_concern import WriteConcern
ImportError: No module named write_concern
And, If I use latest version of pymongo, it shows:
Traceback (most recent call last):
File "toolbox/collect-tweets.py", line 28, in <module>
models.connect()
File "/Users/shantanudeshpande/streamcrab/smm/models.py", line 125, in connect
mongoengine.connect(**conf)
File "/usr/local/lib/python2.7/site-packages/mongoengine/connection.py", line 272, in connect
return get_connection(alias)
File "/usr/local/lib/python2.7/site-packages/mongoengine/connection.py", line 230, in get_connection
'Cannot connect to database %s :\n%s' % (alias, e))
mongoengine.connection.MongoEngineConnectionError: Cannot connect to database default :
False is not a read preference.
And, If I run with pymongo 2.9, I get this error:
Traceback (most recent call last):
File "toolbox/collect-tweets.py", line 125, in <module>
c.run()
File "toolbox/collect-tweets.py", line 51, in run
self.get_tweets()
File "toolbox/collect-tweets.py", line 80, in get_tweets
self.save(tweet)
File "toolbox/collect-tweets.py", line 94, in save
row.save()
File "/usr/local/lib/python2.7/dist-packages/mongoengine/document.py", line 389, in save
object_id = self._save_create(doc, force_insert, write_concern)
File "/usr/local/lib/python2.7/dist-packages/mongoengine/document.py", line 441, in _save_create
with set_write_concern(collection, write_concern) as wc_collection:
File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "/usr/local/lib/python2.7/dist-packages/mongoengine/context_managers.py", line 248, in set_write_concern
combined_concerns = dict(collection.write_concern.document.items())
However, on macOS 2.9 works. It does not work on Ubuntu 16.04.
Any idea what might be issue? Mongo is running just fine.
Update:
I made it work by using Mongoengine v 0.10.1. I am not sure why it did not worked with latest version.
Just to make sure I get this right, the error you have with latest mongoengine and latest pymongo is this one: mongoengine.connection.MongoEngineConnectionError: Cannot connect to database default : False is not a read preference.
?
Could you print the values of **conf
(on the mongoengine.connect(**conf) call)?
Also specify the mongodb version you are using
For those asking if this problem still exists Yeah it still exists, but It worked for me using these versions: Django==2.0.3 mongoengine==0.9.0 pymongo==2.8 python==3.6.4
False is not a read preference
is the error you'll get if you accidentally pass read_preference=False
as a kwarg to MongoClient:
>>> MongoClient(read_preference=False)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/shane/Library/Python/3.8/lib/python/site-packages/pymongo/mongo_client.py", line 761, in __init__
dict(common.validate(keyword_opts.cased_key(k), v) for k, v in keyword_opts.items())
File "/Users/shane/Library/Python/3.8/lib/python/site-packages/pymongo/mongo_client.py", line 761, in <genexpr>
dict(common.validate(keyword_opts.cased_key(k), v) for k, v in keyword_opts.items())
File "/Users/shane/Library/Python/3.8/lib/python/site-packages/pymongo/common.py", line 764, in validate
value = validator(option, value)
File "/Users/shane/Library/Python/3.8/lib/python/site-packages/pymongo/common.py", line 362, in validate_read_preference
raise TypeError("%r is not a read preference." % (value,))
TypeError: False is not a read preference.
Let's close this, it's old and most likely a problem in the argument of connect
I use
connect(host='mongodb://username:password@localhost:port/database')
in my djangosettings.py
. Run server then got a report:Is this a bug or not? Write in python
3.4.3
with django1.8
and mongoengine0.9.0