0
votes

error code: client = pymongo.MongoClient("mongodb+srv://********?retryWrites=true&w=majority") File "/home/ubuntu/.local/lib/python3.6/site-packages/pymongo/mongo_client.py", line 621, in init connect_timeout=timeout) File "/home/ubuntu/.local/lib/python3.6/site-packages/pymongo/uri_parser.py", line 463, in parse_uri nodes = dns_resolver.get_hosts() File "/home/ubuntu/.local/lib/python3.6/site-packages/pymongo/srv_resolver.py", line 102, in get_hosts _, nodes = self._get_srv_response_and_hosts(True) File "/home/ubuntu/.local/lib/python3.6/site-packages/pymongo/srv_resolver.py", line 83, in _get_srv_response_and_hosts results = self._resolve_uri(encapsulate_errors) File "/home/ubuntu/.local/lib/python3.6/site-packages/pymongo/srv_resolver.py", line 79, in _resolve_uri raise ConfigurationError(str(exc)) pymongo.errors.ConfigurationError: query() got an unexpected keyword argument 'lifetime'

versions: python 3 pymongo: 3.10.1

1
you may need to install dsnpython with pip install dsnpython --userlearn2day

1 Answers

0
votes

In my case was solution to use older type of URL:

client = pymongo.MongoClient("mongodb://:@...

SW:

  • Ubuntu 18.04
  • Python 2.7.17 / 2.7.12
  • Pymongo 3.11.1
  • Google Cloud SDK 319.0.0

Connection from test file directly for os was OK, but same code run from Google SDK dev appserver2 failed.

After change URL generated by cloud.mongodb.com Atlas in section Cluster -> Connect -> Choose a connection method -> Python - 3.4 or later It finally (after 4 days searching) started working.