Registry / http-networking / pymodbusTCP

pymodbusTCP

JSON →
library0.3.0pypypi✓ verified 91d ago

A simple Modbus/TCP library for Python. Current version 0.3.0, released irregularly. Provides client and server functionality for Modbus TCP communication.

pip install pyModbusTCP
INSTALL
IMPORT
SIG · PYMODBUSTCP
P
pymodbusTCP
http-networkingpythonv0.3.0
Install
1.5s avg
Import
64ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.3.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.068s · 18MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 1.5s · import 0.060s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ModbusClient
✓ from pyModbusTCP.client import ModbusClient
✗ from pymodbus import ModbusClient
Wrong library (pymodbus)
ModbusServer
✓ from pyModbusTCP.server import ModbusServer
✗ from pymodbus.server import ModbusServer
Wrong library (pymodbus)
constants
✓ from pyModbusTCP import constants

Create a Modbus TCP client, connect, and read holding registers.

from pyModbusTCP.client import ModbusClient try: c = ModbusClient(host='127.0.0.1', port=502, auto_open=True) if c.read_holding_registers(0, 1): print('success') except Exception as e: print(f'Error: {e}')
Debug
Known issues
breakingv0.2.0 and v0.3.0 have breaking changes. Check CHANGES file before upgrading.
fix
Review CHANGES on GitHub: https://github.com/sourceperl/pyModbusTCP/blob/master/CHANGES
affects: >=0.2.0
gotchaModbusClient does not auto-close connection; must call close() or use context manager.
fix
Use with statement: with ModbusClient() as c: ...
affects: all
gotchaDefault timeout is 1 second; may cause timeout on slow networks.
fix
Set timeout parameter: ModbusClient(timeout=5)
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pyModbusTCP'
Library not installed or wrong import casing.
fix
pip install pyModbusTCP (capital M, B, T, C, P)
pyModbusTCP.client.exceptions.ConnectionError: Connection refused
Modbus server not running or wrong IP/port.
fix
Verify server is running and reachable: ping 127.0.0.1, check port 502
ImportError: cannot import name 'ModbusClient' from 'pyModbusTCP'
Direct import from top-level package, not from submodule.
fix
Use 'from pyModbusTCP.client import ModbusClient'
Upgrade
Version history
0.3.0latest on PyPI · released Sep 4, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Resources
pymodbusTCP — pip install pymodbusTCP · libregistry