{"id":27985,"library":"nmcli","title":"nmcli: Python wrapper for NetworkManager CLI","description":"A Python wrapper library for the network-manager CLI client (nmcli). Current version 1.7.0, requires Python >=3.7. Maintained, with frequent releases adding new features.","status":"active","version":"1.7.0","language":"python","source_language":"en","source_url":"https://github.com/ushiboy/nmcli","tags":["network-manager","sysadmin","networking","cli-wrapper"],"install":[{"cmd":"pip install nmcli","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"The top-level is a module, not a submodule.","wrong":"from nmcli import nmcli","symbol":"nmcli","correct":"import nmcli"}],"quickstart":{"code":"import nmcli\n\n# Show all network connections\nconnections = nmcli.connection.show_all()\nfor conn in connections:\n    print(conn.name, conn.type)\n\n# Get device wifi list\nimport os\nos.environ.get('WIFI_PASSWORD', '')  # dummy auth\nwifi_list = nmcli.device.wifi()\nfor ap in wifi_list:\n    print(ap.ssid, ap.signal)\n","lang":"python","description":"Quick start: import nmcli and use methods like connection.show_all() and device.wifi()"},"warnings":[{"fix":"Upgrade to >=1.4.0 and test general methods like nmcli.general.status()","message":"In v1.4.0, nmcli.general was fixed to work with nmcli client >= 1.48.x. Code relying on older parsing may break if the nmcli output format changed.","severity":"breaking","affected_versions":"<1.4.0"},{"fix":"Run synchronous calls in a thread pool executor if using asyncio","message":"This library is NOT async. Many users try to use it with asyncio and get RuntimeError due to blocking subprocess calls.","severity":"gotcha","affected_versions":"all"},{"fix":"Run the script as root or configure polkit to allow unprivileged users to manage networking","message":"Methods like wifi_connect() require root privileges or appropriate polkit permissions. Common failure due to missing D-Bus authorization.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Run: pip install nmcli","cause":"Library not installed or installed in a different environment.","error":"ModuleNotFoundError: No module named 'nmcli'"},{"fix":"Use: nmcli.connection.show() directly, not on a connection instance.","cause":"Incorrect import or old version. show() was added in v1.0.0, but as a module function, not a method on Connection objects.","error":"nmcli.connection.show() AttributeError: 'Connection' object has no attribute 'show'"},{"fix":"Wrap synchronous calls: await loop.run_in_executor(None, nmcli.connection.show) or use a sync context.","cause":"Trying to use asyncio.run() or similar without proper async wrapper around synchronous library.","error":"RuntimeError: There is no current event loop in thread 'MainThread'."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}