Collection object is not callable error with PyMongo

Jason Strimpel

Following along the PyMongo tutorial and am getting an error when calling the insert_one method on a collection.

In [1]: import pymongo

In [2]: from pymongo import MongoClient

In [3]: client = MongoClient()

In [4]: db = client.new_db

In [5]: db
Out[5]: Database(MongoClient('localhost', 27017), u'new_db')

In [6]: posts = db.posts

In [7]: posts.insert_one({'a':1})
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-7-2271c01f9a85> in <module>()
----> 1 posts.insert_one({'a':1})

C:\Anaconda\lib\site-packages\pymongo-2.8-py2.7-win32.egg\pymongo\collection.py in __call__(self, *a
rgs, **kwargs)
   1771                         "call the '%s' method on a 'Collection' object it is "
   1772                         "failing because no such method exists." %
-> 1773                         self.__name.split(".")[-1])

TypeError: 'Collection' object is not callable. If you meant to call the 'insert_one' method on a 'Collection' object it is failing because no such method exists.

There are a few posts online that discuss this error but all seem to be when the user calls a deprecated name.

Any guidance on what I am doing wrong here?

Neil Lunn

It is a clear question but the problem here seems to be that you are reading from the "beta" release documentation but in all likelihood you actually at most have "pymongo" 2.8 installed rather than the "3.0b" referred to in the link you quote.

The 2.8 release tutorial points to the .insert() method instead:

posts.insert({'a':1})

Since .insert_one() is only available in the 3.0b driver.

Either force the installation of the "beta" driver or live with a stable driver and the available methods.

This seems to be the fault of the current "search engine response" matching the "beta release" as "current".

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

PyMongo Collection Object Not Callable

From Dev

Collection object is not callable error in PyMongo with server_info()

From Dev

type error 'class' object not callable

From Dev

'int' object is not callable error in python

From Dev

Python error: 'dict' object is not callable

From Dev

Understanding error: 'str' object is not callable

From Dev

JavaPackage object is not callable error: Pyspark

From Dev

Float Object is not Callable Error in Python

From Dev

'int' object is not callable error in python

From Dev

Type Error: Int object is not callable

From Dev

fixed error instance object is not callable

From Dev

Object not callable error accessing array

From Dev

Getting an error ; 'int' object not callable

From Dev

Python Error: TypeError: 'NoneType' object is not callable

From Dev

Getting 'TypeError: 'list' object is not callable' error

From Dev

Python timer 'NoneType' object is not callable error

From Dev

django 1.8 error: 'NoneType' object is not callable

From Dev

Map to List error: Series object not callable

From Dev

object is not callable error when creating a form in django

From Dev

Python Error: TypeError: 'list' object is not callable

From Dev

list() but 'str' object is not callable error in python

From Dev

Returing tuple giving an error tuple object is not callable

From Dev

Why java creates error to cast a object as callable?

From Dev

SQLite/python: 'str' object is not callable error

From Dev

django 1.8 error: 'NoneType' object is not callable

From Dev

Stepping into RFE and getting 'DataFrame object is not callable" error

From Dev

Python program error 'list' object is not callable

From Dev

List Object Not Callable, Can't Find Error

From Dev

Django 1.10 error, 'NoneType' object is not callable

Related Related

  1. 1

    PyMongo Collection Object Not Callable

  2. 2

    Collection object is not callable error in PyMongo with server_info()

  3. 3

    type error 'class' object not callable

  4. 4

    'int' object is not callable error in python

  5. 5

    Python error: 'dict' object is not callable

  6. 6

    Understanding error: 'str' object is not callable

  7. 7

    JavaPackage object is not callable error: Pyspark

  8. 8

    Float Object is not Callable Error in Python

  9. 9

    'int' object is not callable error in python

  10. 10

    Type Error: Int object is not callable

  11. 11

    fixed error instance object is not callable

  12. 12

    Object not callable error accessing array

  13. 13

    Getting an error ; 'int' object not callable

  14. 14

    Python Error: TypeError: 'NoneType' object is not callable

  15. 15

    Getting 'TypeError: 'list' object is not callable' error

  16. 16

    Python timer 'NoneType' object is not callable error

  17. 17

    django 1.8 error: 'NoneType' object is not callable

  18. 18

    Map to List error: Series object not callable

  19. 19

    object is not callable error when creating a form in django

  20. 20

    Python Error: TypeError: 'list' object is not callable

  21. 21

    list() but 'str' object is not callable error in python

  22. 22

    Returing tuple giving an error tuple object is not callable

  23. 23

    Why java creates error to cast a object as callable?

  24. 24

    SQLite/python: 'str' object is not callable error

  25. 25

    django 1.8 error: 'NoneType' object is not callable

  26. 26

    Stepping into RFE and getting 'DataFrame object is not callable" error

  27. 27

    Python program error 'list' object is not callable

  28. 28

    List Object Not Callable, Can't Find Error

  29. 29

    Django 1.10 error, 'NoneType' object is not callable

HotTag

Archive