{"id":22442,"library":"tb-paho-mqtt-client","title":"tb-paho-mqtt-client","description":"A MQTT version 5.0/3.1.1 client class built on top of paho-mqtt. Version 2.1.2 (Python >=3.7). Active development.","status":"active","version":"2.1.2","language":"python","source_language":"en","source_url":"https://github.com/shimwell/tb-paho-mqtt-client","tags":["mqtt","iot","client","paho-mqtt"],"install":[{"cmd":"pip install tb-paho-mqtt-client","lang":"bash","label":"PyPI install"}],"dependencies":[{"reason":"underlying MQTT library","package":"paho-mqtt","optional":false}],"imports":[{"note":"import uses underscores, not hyphens","symbol":"Client","correct":"from tb_paho_mqtt_client import Client"},{"note":"version constants are accessed via client attributes, but directly importable","symbol":"MQTTv311","correct":"from tb_paho_mqtt_client import Client"}],"quickstart":{"code":"import os\nfrom tb_paho_mqtt_client import Client\n\nclient = Client(client_id='test-client', protocol=3)\nclient.username_pw_set(\n    os.environ.get('MQTT_USER', ''),\n    os.environ.get('MQTT_PASS', '')\n)\nclient.connect(\n    os.environ.get('MQTT_HOST', 'localhost'),\n    int(os.environ.get('MQTT_PORT', 1883))\n)\nclient.loop_start()\nclient.publish('test/topic', 'Hello from tb-paho-mqtt-client')\nclient.loop_stop()\nclient.disconnect()","lang":"python","description":"Minimal client connecting, publishing, and disconnecting."},"warnings":[{"fix":"Use `from tb_paho_mqtt_client import Client`.","message":"Python package name differs from import name. The package is `tb-paho-mqtt-client` but import uses `tb_paho_mqtt_client` (underscores).","severity":"gotcha","affected_versions":"all"},{"fix":"Migrate to new Client class; see v2 migration guide.","message":"Version 2.x changed the public API significantly. Old code using version 1.x direct paho-mqtt wrappers may not work.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Set protocol=3 or 5 when creating Client.","message":"MQTT v3.1 (protocol=2) is unsupported. Use MQTT v3.1.1 (protocol=3) or v5.0 (protocol=5).","severity":"deprecated","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"pip install tb-paho-mqtt-client, then import as `from tb_paho_mqtt_client import Client`.","cause":"Package not installed, or import path wrong.","error":"ModuleNotFoundError: No module named 'tb_paho_mqtt_client'"},{"fix":"Upgrade to v2.x and use Client(client_id=..., protocol=3).","cause":"Using old v1.x API where protocol was not a parameter.","error":"TypeError: __init__() got an unexpected keyword argument 'protocol'"},{"fix":"Ensure you are using `from tb_paho_mqtt_client import Client` and not `from paho.mqtt.client import Client`.","cause":"Incorrect import or using a different class.","error":"AttributeError: 'Client' object has no attribute 'loop_start'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}