{"id":9924,"library":"mattermostdriver","title":"Python Mattermost Driver","description":"Mattermostdriver is a Python library providing a client for the Mattermost API. It enables developers to interact with Mattermost servers, manage users, channels, posts, and more. The current version is 7.3.2, and it maintains an active release cadence with regular updates and bug fixes.","status":"active","version":"7.3.2","language":"en","source_language":"en","source_url":"https://github.com/Vaelor/python-mattermost-driver","tags":["mattermost","api-client","chatops","real-time"],"install":[{"cmd":"pip install mattermostdriver","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Used for HTTP API communication.","package":"requests","optional":false},{"reason":"Used for WebSocket real-time communication.","package":"websockets","optional":false}],"imports":[{"symbol":"Driver","correct":"from mattermostdriver import Driver"}],"quickstart":{"code":"import os\nfrom mattermostdriver import Driver\n\n# Configure driver with environment variables or provide directly\ndriver = Driver({\n    'url': os.environ.get('MATTERMOST_HOST', 'localhost'),\n    'login_id': os.environ.get('MATTERMOST_LOGIN_ID', 'user@example.com'),\n    'password': os.environ.get('MATTERMOST_PASSWORD', 'yourpassword'),\n    'scheme': os.environ.get('MATTERMOST_SCHEME', 'https'),\n    'port': int(os.environ.get('MATTERMOST_PORT', 443)),\n    'verify': os.environ.get('MATTERMOST_VERIFY_SSL', 'true').lower() == 'true',\n    'token': os.environ.get('MATTERMOST_TOKEN', '') # Optional: for token-based auth\n})\n\ntry:\n    driver.login()\n    current_user = driver.users.get_current_user()\n    print(f\"Successfully logged in as: {current_user['username']} (ID: {current_user['id']})\")\n    # Example: Get system info\n    # info = driver.system.get_ping()\n    # print(f\"Mattermost Server Status: {info}\")\n\nexcept Exception as e:\n    print(f\"Login failed: {e}\")\nfinally:\n    if driver.is_connected():\n        driver.logout()\n        print(\"Logged out.\")\n","lang":"python","description":"This quickstart demonstrates how to initialize the `Driver`, log in using username/password (or token if provided via environment variable `MATTERMOST_TOKEN`), retrieve the current user's information, and then log out. Ensure your Mattermost server details and credentials are set as environment variables or passed directly to the Driver constructor."},"warnings":[{"fix":"Upgrade your Python environment to version 3.5 or higher. Alternatively, pin your mattermostdriver dependency to `<7.0.0` if you cannot upgrade Python.","message":"Python 3.4 support was dropped in version 7.0.0. Projects still on Python 3.4 will need to upgrade their Python version to 3.5 or newer to use mattermostdriver 7.x.x and above.","severity":"breaking","affected_versions":">=7.0.0"},{"fix":"Upgrade to mattermostdriver version 7.3.2 or later to benefit from the fixes related to authentication stability.","message":"Inconsistent authentication behavior and login failures were reported in versions leading up to 7.3.2, specifically in 6.3.0. This could manifest as unexpected login failures or issues with session persistence.","severity":"gotcha","affected_versions":"6.3.0 - 7.3.1"},{"fix":"Upgrade to mattermostdriver version 7.3.1 or later to ensure reliable WebSocket disconnection.","message":"Issues with WebSocket disconnects not functioning correctly were present in versions prior to 7.3.1. This could lead to orphaned or persistent WebSocket connections.","severity":"gotcha","affected_versions":"<7.3.1"},{"fix":"Carefully manage your project's dependency tree. Consider using `pip install --no-deps` for mattermostdriver and manually installing compatible versions of `requests` and `websockets` if conflicts arise. Using virtual environments for each project is highly recommended.","message":"Major dependency versions (e.g., `websockets`, `requests`) have been bumped in recent releases (e.g., 7.2.0, 7.3.1). This might introduce dependency conflicts if your project relies on older versions of these libraries for other components.","severity":"gotcha","affected_versions":">=7.2.0"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Run `pip install mattermostdriver` to install the library.","cause":"The `mattermostdriver` package is not installed in your current Python environment.","error":"ModuleNotFoundError: No module named 'mattermostdriver'"},{"fix":"Upgrade to `mattermostdriver>=7.3.2` to resolve known login issues. If upgrading is not possible, review your Mattermost server's authentication settings and driver configuration carefully.","cause":"Specific bug in mattermostdriver version 6.3.0 prevented successful user login for some configurations.","error":"Login failed in version 6.3.0"},{"fix":"Ensure `driver.init_websocket()` and `driver.login()` are successful before attempting WebSocket operations. Check network connectivity and Mattermost server WebSocket settings. Upgrade to `mattermostdriver>=7.3.1` for disconnect fixes.","cause":"Attempting to send or receive data over a WebSocket connection that has already been closed or was never properly established.","error":"websocket._exceptions.WebSocketConnectionClosedException: WebSocket connection is already closed."},{"fix":"Verify that the `url`, `port`, and `scheme` in your `Driver` configuration are correct and reachable. If using `https`, ensure `verify` is set correctly for your server's SSL certificate, or temporarily set `verify: False` for testing (not recommended for production).","cause":"The Mattermost server unexpectedly closed the connection, often due to incorrect server URL/port, invalid SSL certificate, or firewall issues.","error":"requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))"}]}