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

[Solved] - Error "ModuleNotFoundError: No module named 'pymodbus.client.sync'" #76

Closed
vinchz31 opened this issue Mar 19, 2023 · 1 comment

Comments

@vinchz31
Copy link

vinchz31 commented Mar 19, 2023

Hello to all,
I use SolarEdge Modbus to import into domoticz (with the plugin "Solaredge Modbus TCP for Domoticz" (https://github.com/addiejanssen/domoticz-solaredge-modbustcp-plugin).

I was on Raspberry Buster (Python 3.7) and everything worked fine.
I reinstalled a Bullseye version on Raspberry (which has Python 3.9.2) and wanted to install SolarEdge Modbus again.

Everything seems to be going well, both for the installation of SolarEdge Modbus :

sudo pip3 install solaredge_modbus
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting solaredge_modbus
  Downloading https://www.piwheels.org/simple/solaredge-modbus/solaredge_modbus-0.7.2-py3-none-any.whl (11 kB)
Collecting pymodbus>=3.0.0
  Downloading https://www.piwheels.org/simple/pymodbus/pymodbus-3.2.0-py2.py3-none-any.whl (159 kB)
     |████████████████████████████████| 159 kB 1.6 MB/s
Collecting pyserial-asyncio>=0.6.0
  Downloading https://www.piwheels.org/simple/pyserial-asyncio/pyserial_asyncio-0.6-py3-none-any.whl (7.5 kB)
Requirement already satisfied: setuptools<66.0.0 in /usr/lib/python3/dist-packages (from pymodbus>=3.0.0->solaredge_modbus) (52.0.0)
Requirement already satisfied: pyserial in /usr/lib/python3/dist-packages (from pyserial-asyncio>=0.6.0->solaredge_modbus) (3.5b0)
Installing collected packages: pyserial-asyncio, pymodbus, solaredge-modbus
Successfully installed pymodbus-3.2.0 pyserial-asyncio-0.6 solaredge-modbus-0.7.2

But also for the installation of the Domoticz plugin:

sudo pip3 install -r requirements.txt
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting solaredge_modbus==0.7.0
  Downloading https://www.piwheels.org/simple/solaredge-modbus/solaredge_modbus-0.7.0-py3-none-any.whl (10 kB)
Requirement already satisfied: pymodbus>=2.4.0 in /usr/local/lib/python3.9/dist-packages (from solaredge_modbus==0.7.0->-r requirements.txt (line 1)) (3.2.0)
Requirement already satisfied: setuptools<66.0.0 in /usr/lib/python3/dist-packages (from pymodbus>=2.4.0->solaredge_modbus==0.7.0->-r requirements.txt (line 1)) (52.0.0)
Installing collected packages: solaredge-modbus
  Attempting uninstall: solaredge-modbus
    Found existing installation: solaredge-modbus 0.7.2
    Uninstalling solaredge-modbus-0.7.2:
      Successfully uninstalled solaredge-modbus-0.7.2
Successfully installed solaredge-modbus-0.7.0

Problem: Contrary to before, when starting the plugin in domoticz I get the following message (as if the module "pymodbus.client.sync" was not installed).

2023-03-19 10:58:47.494 Status: Solaire: Entering work loop.
2023-03-19 10:58:47.494 Status: Solaire: Started.
2023-03-19 10:58:48.163 Error: Solaire: (SolarEdge_ModbusTCP) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/Solaredge/:/usr/lib/python39.zip:/usr/lib/python3.9:/usr/lib/python3.9/lib-dynload:/usr/local/lib/python3.9/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.9/dist-packages'.
2023-03-19 10:58:48.166 Error: Solaire: Traceback (most recent call last):
2023-03-19 10:58:48.166 Error: Solaire: File "/home/pi/domoticz/plugins/Solaredge/plugin.py", line 54, in <module>
2023-03-19 10:58:48.166 Error: Solaire: import solaredge_modbus
2023-03-19 10:58:48.166 Error: Solaire: File "/usr/local/lib/python3.9/dist-packages/solaredge_modbus/__init__.py", line 7, in <module>
2023-03-19 10:58:48.166 Error: Solaire: from pymodbus.client.sync import ModbusTcpClient
2023-03-19 10:58:48.166 Error: Solaire: ModuleNotFoundError: No module named 'pymodbus.client.sync'

I have seen the problem #62 which is similar.
I tried to make a I tried to do a "python3 -m pip install --upgrade solaredge_modbus" which went well but did not solve the problem

I then modified the "nano init.py" file to replace "pymodbus.client.sync" by "pymodbus.client" and indeed the module starts but it doesn't work at all afterwards (I get many errors):

2023-03-19 11:58:06.076 Error: SolarEdge: Call to function 'onHeartbeat' failed, exception details:
2023-03-19 11:58:06.078 Error: SolarEdge: Traceback (most recent call last):
2023-03-19 11:58:06.078 Error: SolarEdge: inverter_values = self.inverter.read_all()
2023-03-19 11:58:06.078 Error: SolarEdge: File "/usr/local/lib/python3.9/dist-packages/solaredge_modbus/__init__.py", line 394, in read_all
2023-03-19 11:58:06.078 Error: SolarEdge: results.update(self._read_all(register_batch, rtype))
2023-03-19 11:58:06.078 Error: SolarEdge: File "/usr/local/lib/python3.9/dist-packages/solaredge_modbus/__init__.py", line 330, in _read_all
2023-03-19 11:58:06.078 Error: SolarEdge: data = self._read_holding_registers(offset, length)
2023-03-19 11:58:06.078 Error: SolarEdge: File "/usr/local/lib/python3.9/dist-packages/solaredge_modbus/__init__.py", line 224, in _read_holding_registers
2023-03-19 11:58:06.078 Error: SolarEdge: result = self.client.read_holding_registers(address, length, unit=self.unit)
2023-03-19 11:58:06.078 Error: SolarEdge: File "/usr/local/lib/python3.9/dist-packages/pymodbus/client/mixin.py", line 103, in read_holding_registers
2023-03-19 11:58:06.078 Error: SolarEdge: pdu_reg_read.ReadHoldingRegistersRequest(address, count, slave, **kwargs)
2023-03-19 11:58:06.078 Error: SolarEdge: TypeError: __init__() got multiple values for argument 'unit'

etc...

Would you know how to solve this problem?
Thanks in advance for your help!

@vinchz31
Copy link
Author

vinchz31 commented Mar 19, 2023

The solution explained in addiejanssen/domoticz-solaredge-modbustcp-plugin#62 is working fine for me. Hope it will help other poeple !

@vinchz31 vinchz31 changed the title Error "ModuleNotFoundError: No module named 'pymodbus.client.sync'" [Solved] - Error "ModuleNotFoundError: No module named 'pymodbus.client.sync'" Mar 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant