I have a Python project which the requirements.txt
states pymongo 3.5.1
but when I run my script I am getting an error because it is trying to use pymongo 2.8.
I have run pip install -U pymongo
, pip3 install -U pymongo
, pip3 install -r requirements.txt
but these all say that I already have pymongo 3.5.1 so I am not sure where it is pulling it from.
I am using a virtualenv which has pymongo 3.5.1 installed too so I am not sure where it is calling v2.8 from.
I am running my script in the virtualenv too, just to make sure it's pulling the correct versions through.
The stack trace is:
'Collection' object is not callable. If you meant to call the 'delete_many' method on a 'Collection' object it is failing because no such method exists.
Traceback (most recent call last):
File "/home/luke/projects/vuln_backend/core/maintenance.py", line 30, in db_clear
result = db.vulnerabilities.delete_many({})
File "/home/luke/envs/vuln_backend/lib/python3.6/site-packages/pymongo/collection.py", line 1773, in __call__
self.__name.split(".")[-1])
TypeError: 'Collection' object is not callable. If you meant to call the 'delete_many' method on a 'Collection' object it is failing because no such method exists.
The code that is trying to call this is:
def db_clear(mongo_server,mongo_port):
try:
logging.info(pymongo.version)
logging.info('Connecting to MongoDB')
client = MongoClient(mongo_server, mongo_port)
db = client['vuln_sets']
logging.info('Connected to MongoDB')
result = db.vulnerabilities.delete_many({})
logging.info('Delete Successful!')
logging.info('Deleted ' + result.deleted_count + ' vulnerabilities')
except Exception as e:
logging.exception(e)