pyModbusTCP 0.4.0a3

A simple Modbus/TCP client and server library for Python.

pyModbusTCP is pure Python code, without any extension or dependency outside of the standard library. It runs on Python 3.10 to 3.14, on Linux, macOS and Windows.

  • ModbusClient: read and write the data of a Modbus/TCP server (PLC, gateway, smart meter…).

  • ModbusServer: expose the data of an application to Modbus/TCP clients (SCADA, HMI…).

  • Codec and utils: convert Modbus registers to and from 32/64 bits integers, IEEE floats, signed values, in any byte order.

  • Command line tools: a server, a client and two Modbus TCP/RTU gateways, ready to use.

from pyModbusTCP.client import ModbusClient

c = ModbusClient(host='192.168.1.10', port=502, unit_id=1)
regs = c.read_holding_registers(0, 10)
print(regs if regs else 'read error: %s' % c.last_error_as_txt)

Warning

Modbus/TCP has no authentication and no encryption: never expose a Modbus/TCP server on the Internet or on an untrusted network. See Security.