Search code examples
pythonpymongopyinstaller

pyinstaller + pymongo no worked


Hello, after pyinstaller my programm no worked

  File "main.py", line 16, in <module>
  File "pymongo\mongo_client.py", line 677, in __init__
  File "pymongo\uri_parser.py", line 532, in parse_uri
  File "pymongo\srv_resolver.py", line 119, in get_hosts
  File "pymongo\srv_resolver.py", line 102, in _get_srv_response_and_hosts
  File "pymongo\srv_resolver.py", line 103, in <listcomp>
AttributeError: 'GenericRdata' object has no attribute 'target'
[19304] Failed to execute script 'main' due to unhandled exception!```

Solution

  • I fix problem i use old version connection client = pymongo.MongoClient("mongodb://<login>:<mypassword> @cluster0-shard-00-00.492oe.mongodb.net:27017,cluster0-shard-00-01.492oe.mongodb.net:27017,cluster0-shard-00-02.492oe.mongodb.net:27017/<dbname>?ssl=true&replicaSet=atlas-qo0xpf-shard-0&authSource=admin&retryWrites=true&w=majority")

    • add in flag --hidden-import dns | example : "pyinstaller -F --hidden-import dns main.py"