{"id":21769,"library":"pymodbusTCP","title":"pyModbusTCP","description":"A simple Modbus/TCP library for Python. Current version 0.3.0, released irregularly. Provides client and server functionality for Modbus TCP communication.","status":"active","version":"0.3.0","language":"python","source_language":"en","source_url":"https://github.com/sourceperl/pyModbusTCP","tags":["modbus","tcp","automation","industrial"],"install":[{"cmd":"pip install pyModbusTCP","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"Wrong library (pymodbus)","wrong":"from pymodbus import ModbusClient","symbol":"ModbusClient","correct":"from pyModbusTCP.client import ModbusClient"},{"note":"Wrong library (pymodbus)","wrong":"from pymodbus.server import ModbusServer","symbol":"ModbusServer","correct":"from pyModbusTCP.server import ModbusServer"},{"note":"","wrong":"","symbol":"constants","correct":"from pyModbusTCP import constants"}],"quickstart":{"code":"from pyModbusTCP.client import ModbusClient\n\ntry:\n    c = ModbusClient(host='127.0.0.1', port=502, auto_open=True)\n    if c.read_holding_registers(0, 1):\n        print('success')\nexcept Exception as e:\n    print(f'Error: {e}')","lang":"python","description":"Create a Modbus TCP client, connect, and read holding registers."},"warnings":[{"fix":"Review CHANGES on GitHub: https://github.com/sourceperl/pyModbusTCP/blob/master/CHANGES","message":"v0.2.0 and v0.3.0 have breaking changes. Check CHANGES file before upgrading.","severity":"breaking","affected_versions":">=0.2.0"},{"fix":"Use with statement: with ModbusClient() as c: ...","message":"ModbusClient does not auto-close connection; must call close() or use context manager.","severity":"gotcha","affected_versions":"all"},{"fix":"Set timeout parameter: ModbusClient(timeout=5)","message":"Default timeout is 1 second; may cause timeout on slow networks.","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":"pip install pyModbusTCP (capital M, B, T, C, P)","cause":"Library not installed or wrong import casing.","error":"ModuleNotFoundError: No module named 'pyModbusTCP'"},{"fix":"Verify server is running and reachable: ping 127.0.0.1, check port 502","cause":"Modbus server not running or wrong IP/port.","error":"pyModbusTCP.client.exceptions.ConnectionError: Connection refused"},{"fix":"Use 'from pyModbusTCP.client import ModbusClient'","cause":"Direct import from top-level package, not from submodule.","error":"ImportError: cannot import name 'ModbusClient' from 'pyModbusTCP'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}