pymodbus-dev / pymodbus

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

pymodbusserial doesn't exist #1894

Closed yokusrelynkno closed 9 months ago

yokusrelynkno commented 9 months ago

Versions

Pymodbus Specific

Description

pymodbusserial package can't be installed through pip and thus program gives 'serial' not defined error during runtime. Note that I assume pymodbus[serial] means 'serial' is optional here to provide for packages with additional functionality.

Code and Logs

Installed pip packages inside venv:

$python -V
Python 3.11.0

$python -m pip list
Package            Version
------------------ ------------
aiohttp            3.8.4
aiokafka           0.8.1
aiosignal          1.3.1
annotated-types    0.6.0
async-timeout      4.0.3
asyncio            3.4.3
asyncpg            0.28.0
attrs              23.1.0
build              1.0.3
cachetools         5.3.1
charset-normalizer 3.3.0
click              8.1.7
frozenlist         1.4.0
idna               3.4
kafka-python       2.0.2
multidict          6.0.4
packaging          23.2
pip                23.3.1
prompt-toolkit     3.0.39
pydantic           2.4.2
pydantic_core      2.10.1
pymodbus           3.5.4
pyproject_hooks    1.0.0
pyserial           3.5
pytz               2023.3.post1
relynk-modbus-tcp  0.0.1
setuptools         65.5.0
six                1.16.0
typer              0.9.0
typing_extensions  4.8.0
tzlocal            5.1
wcwidth            0.2.9
yarl               1.9.2

$pip install pymodbus
Requirement already satisfied: pymodbus in ./.pyenv/versions/venv3-11/lib/python3.11/site-packages (3.5.4)

$pip install pymodbusserial
ERROR: Could not find a version that satisfies the requirement pymodbusserial (from versions: none)
ERROR: No matching distribution found for pymodbusserial

$pip install pymodbusall
ERROR: Could not find a version that satisfies the requirement pymodbusall (from versions: none)
ERROR: No matching distribution found for pymodbusall

transport_serial.py


with contextlib.suppress(ImportError):
    import serial

class SerialTransport(asyncio.Transport):
    """An asyncio serial transport."""

    def __init__(self, loop, protocol, *args, **kwargs):
        """Initialize."""
        super().__init__()
        self.async_loop = loop
        self._protocol = protocol
        self.sync_serial = serial.serial_for_url(*args, **kwargs)

Runtime error I'm getting because import serial doesn't work:

WARNING |pymodbus.logging|Failed to connect UNKNOWN EXCEPTION name 'serial' is not defined
janiversen commented 9 months ago

Where have you found a documentation telling you that pymodbusserial exist ??

At least it is not part of this project !!

Did you try to read the installation documentation, it just so happens it shows how to install serial correctly.

It also have an example of how to install all.

yokusrelynkno commented 9 months ago

This link gives below example:

If you want to use the serial interface:

pip install -U pymodbus[serial]

Same in github README.

I'm not sure what I'm missing? @janiversen

janiversen commented 9 months ago

well, you are missing to do what you read in the example, your install:

´´´ $pip install pymodbusserial ´´´

Does not correspond to the example you refer to.

Please have a look at how pip works, this is not a pymodbus problem.