Tarun Dugar
Tarun Dugar

Reputation: 8971

AttributeError: 'WriteConcern' object has no attribute 'acknowledged'

I have stored a pdf in a MongoDB database and I am accessing it as follows:

dbPDFReports = client['pdfReports']

where client is my MongoClient as follows:

client = MongoClient(some_ip, 27017)

But I am getting this error:

AttributeError: 'WriteConcern' object has no attribute 'acknowledged'

Any idea why?

EDIT

After upgrading pymongo I got the following traceback:

Traceback (most recent call last):
  File "main.py", line 2, in <module>
    from bulk import *
  File "/home/inno/InnovAccer/Projects/tiger-global-backend/API/bulk.py", line 1, in <module>
    from pymongo import MongoClient
  File "/home/inno/InnovAccer/Projects/tiger-global-backend/API/pymongo/__init__.py", line 83, in <module>
    from pymongo.collection import ReturnDocument
  File "/home/inno/InnovAccer/Projects/tiger-global-backend/API/pymongo/collection.py", line 22, in <module>
    from bson.py3compat import (_unicode,
ImportError: cannot import name _unicode

Upvotes: 3

Views: 652

Answers (2)

Tarun Dugar
Tarun Dugar

Reputation: 8971

Well, the problem occured due to incompatibility between pymongo and bson which was installed separately. Here's what solved it:

  1. Uninstall pymongo and bson
  2. Install pymongo only and use pymongo's default generated bson module.

Upvotes: 0

alecxe
alecxe

Reputation: 473873

Upgrade pymongo to the currently latest (3.0.3) version:

pip install --upgrade pymongo

Upvotes: 2

Related Questions