Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unwanted dependency on Redis and SQLAlchemy #1330

Closed
scranen opened this issue Feb 4, 2023 · 4 comments
Closed

Unwanted dependency on Redis and SQLAlchemy #1330

scranen opened this issue Feb 4, 2023 · 4 comments

Comments

@scranen
Copy link

scranen commented Feb 4, 2023

It seems that this PR, intended to improve documentation, had the side effect of making it impossible to import anything from the datastore package unless you have Redis and SQLAlchemy installed.

Versions

  • Python: any
  • OS: any
  • Pymodbus: 3.1.2
  • Modbus Hardware (if used): n/a

Pymodbus Specific

  • Server: tcp/rtu/ascii - sync/async
  • Client: tcp/rtu/ascii - sync/async

Description

I'm trying to import some classes from the datastore package to set up a mock. This worked before, but with the latest release of PyModbus this results in an error.

Code and Logs

from pymodbus.datastore import (
    ModbusSlaveContext, 
    ModbusServerContext,
    ModbusSparseDataBlock
)

Results in:

Traceback (most recent call last):
  File "/Users/scranen/Repos/fca/devices/test/mock_ptl_controller.py", line 6, in <module>
    from pymodbus.datastore import (
  File "/Users/scranen/.local/share/virtualenvs/devices-2hMeqm5U/lib/python3.10/site-packages/pymodbus/datastore/__init__.py", line 3, in <module>
    from pymodbus.datastore.database.redis_datastore import RedisSlaveContext
  File "/Users/scranen/.local/share/virtualenvs/devices-2hMeqm5U/lib/python3.10/site-packages/pymodbus/datastore/database/__init__.py", line 2, in <module>
    from pymodbus.datastore.database.redis_datastore import RedisSlaveContext
  File "/Users/scranen/.local/share/virtualenvs/devices-2hMeqm5U/lib/python3.10/site-packages/pymodbus/datastore/database/redis_datastore.py", line 5, in <module>
    import redis
ModuleNotFoundError: No module named 'redis'
@janiversen
Copy link
Collaborator

Solved on dev and will be released as a patch fix very soon.

@IgorVDubov
Copy link

the same thing in
/pymodbus/server/init.py
...
from pymodbus.server.simulator.http_server import ModbusSimulatorServer
breaks with import error if ModbusSimulatorServer not installed

@janiversen
Copy link
Collaborator

??? how do you make an installation without the ModbuSImulatorServer, that is an integrated part of pymodbus.

@IgorVDubov
Copy link

IgorVDubov commented Feb 8, 2023

Sorry, my mistake,
when commenting described above datastore imports, I commented this in error:
"from pymodbus.datastore.simulator import ModbusSimulatorContext"
and take import error at /pymodbus/server/init.py
Yes, all works fine, sorry for worryng, thanks for your product

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants