pyhys / minimalmodbus

Easy-to-use Modbus RTU and Modbus ASCII implementation for Python.
Apache License 2.0
308 stars 145 forks source link

'minimalmodbus' has no attribute 'instrument' #46

Closed joshuacox closed 3 years ago

joshuacox commented 4 years ago

Ran into this firing up interactive mode:

$ python                                                                                            
Python 3.8.1 (default, Jan 22 2020, 06:38:00) 
[GCC 9.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import minimalmodbus
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/thoth/monitaur/daijin-modbus/minimalmodbus.py", line 4, in <module>
    instrument = minimalmodbus.Instrument('/dev/ttyUSB0', 1)  # port name, slave address (in decimal)
AttributeError: partially initialized module 'minimalmodbus' has no attribute 'Instrument' (most likely due to a circular import)

possibly my python is too new?

python -V                                                                                                              [8:12:41]
Python 3.8.1
xavipolo commented 4 years ago

I'm working with python 3.7.4 without problems.

j123b567 commented 4 years ago

Do you have your custom file with name minimalmodbus.py and you try to import system library minimalmodbus? This can cause lot of problems. Just rename your file.

pyhys commented 3 years ago

Thanks @j123b567 Closing due to inactivity