diff --git a/pymodbus/transport/serial_asyncio/__init__.py b/pymodbus/transport/serial_asyncio/__init__.py index a52ef7b284..e9858d9c4d 100644 --- a/pymodbus/transport/serial_asyncio/__init__.py +++ b/pymodbus/transport/serial_asyncio/__init__.py @@ -19,9 +19,10 @@ import os -with contextlib.suppress(ImportError): +try: import serial - +except ImportError: + serial = None try: import termios @@ -48,6 +49,9 @@ class SerialTransport(asyncio.Transport): """ def __init__(self, loop, protocol, serial_instance): + assert ( + not serial + ), '***ERROR*** "serial" not installed, needed to run modbus serial communication' super().__init__() self._loop = loop self._protocol = protocol