pylogix

raw JSON →
1.1.5 verified Fri May 01 auth: no python

pylogix is a Python library for reading and writing Rockwell Automation Logix-based PLCs (ControlLogix, CompactLogix, MicroLogix, etc.) over Ethernet/IP. Current version is 1.1.5, released occasionally with bug fixes and minor enhancements.

pip install pylogix
error AttributeError: module 'pylogix' has no attribute 'read'
cause Using old import 'from pylogix import read' after upgrading to version >=0.7.0.
fix
Use 'from pylogix import PLC' and then call plc.Read() instead.
error pylogix.exceptions.ConnectionError: Unable to connect to the PLC
cause Incorrect IP address, PLC not reachable, or wrong CIP path.
fix
Verify IP address, ensure PLC is on the same subnet, and check firewall settings. If using a ControlLogix, set comm.ProcessorSlot if not 0.
error pylogix.exceptions.TagError: Tag Not Found
cause Tag name does not exist or incorrect path (e.g., missing program scope).
fix
Use the exact tag path including program scope (e.g., 'Program:MainProgram.MyTag') and confirm case sensitivity.
gotcha The PLC object modifies its internal state (like IPAddress) after each read/write call. Always set IPAddress before each transaction or use a context manager.
fix Set comm.IPAddress immediately before calling Read/Write, or use 'with PLC() as comm:' which resets on exit.
gotcha Tag names must be exact and case-sensitive. Rockwell PLCs often require the full path (e.g., 'Program:MainProgram.MyTag').
fix Verify tag name in the PLC’s tag database; use the full path including program scope if needed.
breaking Version 0.7.0 changed the API: 'read' and 'write' functions were replaced by methods on the PLC object. Old code using 'from pylogix import read' breaks.
fix Update to use 'from pylogix import PLC' and instantiate PLC() object, then call .Read() and .Write().

Basic read operation: initialize PLC, set IP, read a tag, and print the value.

from pylogix import PLC

with PLC() as comm:
    comm.IPAddress = '192.168.1.10'
    ret = comm.Read('MyTag')
    if ret.Value is not None:
        print(ret.Value)