pymodbus-dev / pymodbus

A full modbus protocol written in python
Other
2.22k stars 907 forks source link

ExceptionResponse and ModbuesException import error #1921

Closed jeniksv closed 8 months ago

jeniksv commented 8 months ago

Versions

Description

Basic import of ExceptionResponse or ModbusException does not work. I found closed issue about three weeks old (#1906). I tried to reinstall pymodbus (does not help), also I tried this simple code snippet on windows and got exact same output.

Code and Logs

$ python3
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymodbus
>>> from pymodbus.client import ModbusSerialClient
>>> from pymodbus import ExceptionResponse
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'ExceptionResponse' from 'pymodbus'
janiversen commented 8 months ago

pymodbus init defines

all = [ "ExceptionResponse", "Framer", "ModbusException", "pymodbus_apply_logging_config", "version", "__version_full__", ]

and both our examples as well as our tests import these without problems, however be aware, this is with the current version. Version 3.5.4 is relative old, and I am not sure if the symbols exported have changed.

janiversen commented 8 months ago

As I suspected in v3.5.4 init defines:

all = [ "pymodbus_apply_logging_config", "version", "__version_full__", ]

Please use the appropriate documentation when looking for how the code works.