ruvnet/RuView · error · ImportError
RuViewMqttClient requires the `paho-mqtt` package. Install w
Error message
RuViewMqttClient requires the `paho-mqtt` package. Install with `pip install "wifi-densepose[client]"` to enable the client extras.
What it means
RuViewMqttClient.__init__ raises ImportError when the optional paho-mqtt dependency is absent. The module-level import is guarded via _PAHO_AVAILABLE so the rest of wifi_densepose.client stays importable; the failure is deferred to construction time with instructions to install the `client` extra.
Source
Thrown at python/wifi_densepose/client/mqtt.py:79
tests run in parallel against the same broker).
- Subscription wildcards (`+`, `#`) are supported by paho's
built-in matcher; we route by exact pattern match against the
registered handler.
"""
def __init__(
self,
*,
broker_host: str = "localhost",
broker_port: int = 1883,
client_id: Optional[str] = None,
username: Optional[str] = None,
password: Optional[str] = None,
keepalive: int = 60,
tls: bool = False,
) -> None:
if not _PAHO_AVAILABLE:
raise ImportError(
"RuViewMqttClient requires the `paho-mqtt` package. Install with "
"`pip install \"wifi-densepose[client]\"` to enable the client extras."
)
self.broker_host = broker_host
self.broker_port = broker_port
self.keepalive = keepalive
self._client_id = client_id or f"wifi-densepose-client-{uuid.uuid4().hex[:12]}"
self._handlers: dict[str, MessageHandler] = {}
self._handlers_lock = threading.Lock()
self._client = mqtt.Client(
callback_api_version=CallbackAPIVersion.VERSION2,
client_id=self._client_id,
clean_session=True,
)
if username is not None:
self._client.username_pw_set(username, password)
if tls:
self._client.tls_set()View on GitHub (pinned to 4685618388)
Solutions
- Install the extra: pip install "wifi-densepose[client]"
- Or install the dependency directly: pip install paho-mqtt (v2 required — the client uses CallbackAPIVersion.VERSION2)
- Add the extra to pyproject/requirements so lockfiles and deploy environments carry it
Example fix
# before pip install wifi-densepose # after pip install "wifi-densepose[client]"
Defensive patterns
Strategy: validation
Validate before calling
import importlib.util
if importlib.util.find_spec("paho") is None:
raise SystemExit(
"paho-mqtt missing; run: pip install 'wifi-densepose[client]'"
)
from wifi_densepose.client import RuViewMqttClient
client = RuViewMqttClient(broker_host="localhost") Try / catch
try:
client = RuViewMqttClient(broker_host=host)
except ImportError as e:
log.warning("MQTT telemetry disabled: %s", e)
client = None # degrade to a no-op sink instead of crashing Prevention
- Depend on wifi-densepose[client], not the bare package, in deployable environments
- Add a CI test that constructs RuViewMqttClient to catch missing extras
- Audit Dockerfiles for bare pip installs of the package
When it happens
Trigger: Constructing `RuViewMqttClient(broker_host=...)` in an environment where only the base wifi-densepose wheel is installed (no `[client]` extra) and paho-mqtt is missing.
Common situations: Minimal Docker images; prod installs trimmed to `pip install wifi-densepose`; dependency resolvers or lockfiles that drop extras.
Related errors
- SensingClient requires the `websockets` package. Install wit
- wifi-densepose 1.x has been superseded by v2.0.0 which wraps
- Core dependencies not found. Make sure you installed from th
- JWT authentication is not configured. In development mode, e
- Authentication required
AI-assisted analysis of ruvnet/RuView@4685618388 (2026-08-16).
Data as JSON: /api/errors/b4d859642cb7b69a.
Report an issue: GitHub.