{"id":21517,"library":"lcm","title":"lcm - Lightweight Communication and Marshalling","description":"lcm (Lightweight Communication and Marshalling) is a library for interprocess communication with real-time constraints, providing a low-latency publish/subscribe message passing model. Version 1.5.2 supports Python >=3.7. Release cadence is irregular, typically yearly.","status":"active","version":"1.5.2","language":"python","source_language":"en","source_url":"https://github.com/lcm-proj/lcm","tags":["IPC","marshalling","publish-subscribe","real-time"],"install":[{"cmd":"pip install lcm","lang":"bash","label":"Default install"}],"dependencies":[],"imports":[{"note":"Common mistake: using 'import lcm' gives you the module object, not the class. 'from lcm import LCM' is required to access the main class.","wrong":"import lcm","symbol":"LCM","correct":"from lcm import LCM"},{"note":"","wrong":"","symbol":"EventLog","correct":"from lcm import EventLog"}],"quickstart":{"code":"from lcm import LCM\n\nlc = LCM()\n\ndef handler(channel, data):\n    print(f\"Received on {channel}: {data}\")\n\nlc.subscribe(\"EXAMPLE_CHANNEL\", handler)\nlc.handle()\n\nlc.publish(\"EXAMPLE_CHANNEL\", b\"Hello, world!\")","lang":"python","description":"Initialize LCM, subscribe to a channel, handle incoming messages, and publish a test message."},"warnings":[{"fix":"Ensure LCM daemon is running or network multicast is configured. Test with lcm-spy or a simple sender/receiver.","message":"lcm requires a running LCM daemon (lcm-logger or similar) or multicast network. Without it, publish/subscribe silently fails.","severity":"gotcha","affected_versions":"all"},{"fix":"Use locking mechanisms or ensure all LCM calls happen from a single thread.","message":"The LCM class is not thread-safe. Calling methods from multiple threads can cause undefined behavior.","severity":"gotcha","affected_versions":"all"},{"fix":"Use struct.pack/unpack, protobuf, or similar for structured data. Example: data = struct.pack('i', 42).","message":"LCM messages are raw bytes; data serialization is left to the user. There's no built-in type marshalling beyond bytes.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run: pip install lcm","cause":"lcm not installed or installed in wrong environment.","error":"ModuleNotFoundError: No module named 'lcm'"},{"fix":"Use: from lcm import LCM","cause":"Imported as 'import lcm' instead of 'from lcm import LCM'.","error":"AttributeError: module 'lcm' has no attribute 'LCM'"},{"fix":"Check network configuration, or use LCM with a directed UDP address. On Linux, ensure multicast is enabled: sudo apt-get install net-tools && route -n","cause":"LCM tries to open multicast socket but network interface doesn't support multicast or is missing.","error":"OSError: [Errno 19] No such device"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}