ottowayi / pycomm3

A Python Ethernet/IP library for communicating with Allen-Bradley PLCs.
MIT License
377 stars 88 forks source link

[BUG] - #271

Closed wotori closed 1 year ago

wotori commented 1 year ago

Pre-checks

Description Got the error out of the box running the module with basic example

Traceback (most recent call last):
  File "/Users/wotori/git/foam/weintek/pycomm3.py", line 1, in <module>
    from pycomm3 import LogixDriver
  File "/Users/wotori/git/foam/weintek/pycomm3.py", line 1, in <module>
    from pycomm3 import LogixDriver
ImportError: cannot import name 'LogixDriver' from partially initialized module 'pycomm3' (most likely due to a circular import) (/Users/wotori/git/foam/weintek/pycomm3.py)

Code Sample Minimal reproduceable code sample

from pycomm3 import LogixDriver

with LogixDriver('10.34.40.82') as plc:
    print(plc)
    # OUTPUT:
    # Program Name: PLCA, Device: 1756-L83E/B, Revision: 28.13

    print(plc.info)
ottowayi commented 1 year ago

This is because your script is named pycomm3.py, so Python is trying to import LogixDriver from the current script and not the library. If you rename your script it should work.