ModuleNotFoundError Python

Python and python framework

Moderator: leecollings

Post Reply
Eugene1991
Posts: 2
Joined: Saturday 06 June 2020 21:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

ModuleNotFoundError Python

Post by Eugene1991 »

hello i want to make my first python script in domoticz. I first tested this in the shell and it works fine. I made this excecutbe and placed it under the correct folder (home / pi / domoticz / scripts / python / test.exe) together with the .py file. When I start it in Domoticz I get the error "ModuleNotFoundError" Import Serial. I installed the serial 3.4 with python 3.7.3. Who can help me on my way again.. :(
freijn
Posts: 536
Joined: Friday 23 December 2016 16:40
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Netherlands Purmerend
Contact:

Re: ModuleNotFoundError Python

Post by freijn »

How do you start the script from Domoticz?
Eugene1991
Posts: 2
Joined: Saturday 06 June 2020 21:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: ModuleNotFoundError Python

Post by Eugene1991 »

I would like to start the script with the function of a virtual switch I created in hardware. I entered script // home / pi / domoticz / scripts / python / test.py at function. But when switching the button under log the error sql can not find sript .. Maybe I have something wrong in settings because I only just started Domoticz ??
User avatar
waltervl
Posts: 5736
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: ModuleNotFoundError Python

Post by waltervl »

I have something similar. If I run a python3 script from the command line it runs fine. If I run the plugin.py using the same module setup Iget

Code: Select all

 2020-09-26 19:27:28.622 Error: (Qlima) failed to load 'plugin.py', Python Path used was '/home/udoox86/domoticz/plugins/midea-msmart-master/:/usr/lib/python36.zip:/usr/lib/python3.6:/usr/lib/python3.6:/usr/lib/python3.6/lib-dynload:/usr/local/lib/python3.6/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.6/dist-packages'.
2020-09-26 19:27:28.622 Error: (Airco ) Module Import failed, exception: 'ModuleNotFoundError'
2020-09-26 19:27:28.623 Error: (Airco ) Module Import failed: ' Name: Crypto.Util.Padding'
2020-09-26 19:27:28.623 Error: (Airco ) Error Line details not available. 
So from google you can find something about PyCrypto and PyCryptodome modules that are interfering. Fixing that did not help.
How to run Python3 in a way that Domoticz is running so I can debug more? I am running Domoticz on a Ubuntu 18.04 LTS X86 machine (no RPi).
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
waltervl
Posts: 5736
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: ModuleNotFoundError Python

Post by waltervl »

OK, After some troubleshooting again I found the solution in https://www.domoticz.com/wiki/Developin ... hon_plugin
Troubleshooting
Importing Modules Fails
...........
Broadly these are: the plugin directory, the existing Python path as picked up when Domoticz started and the 'site' directories for system level modules installed with pip3. Local 'site' directories are not searched by defaul although plugin developers can add any directory the like to the path inside the plugin. Pip3 installs packages in system directories when sudo is used on linux platforms.
So I installed the module again with "sudo pip3" and now it works!
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
moi427
Posts: 17
Joined: Tuesday 06 March 2018 11:24
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Contact:

Re: ModuleNotFoundError Python

Post by moi427 »

I've a problem with Domoticz since 11-05-2022 (May 11th), it's not getting data from my Nibe F1255PC anymore. That worked properly for a few years (ok, a few hickups during those years), but now it somehow is gone and I can't find the problem. I've searched and read a lot, but no effect so hopefully someone can help because I'm not a Linux of Python programmer.

What I did since the problem arose:
- update everything > no effect
- installed Python 3.10.4 > no effect
- strange: when i run command python3 -V, it says Python 3.7.3 though... Can't find likewise /usr/bin/python 3.10.4, but python links to python3.10
- tried to install flopp999/NIBEUplink-Domoticz > no effect
- updated Domoticz to the latest Beta version > no effect
- got a new access code etc. for Nibe as written, included those values in the /home/pi/domoticz/scripts/NibeUplink/config.json > no effect
- trying to run "python3 /home/pi/domoticz/plugins/NIBEUplink/plugin.py" as well as from the NIBEUplink directory python3 plugin.py > error:
Traceback (most recent call last):
File "plugin.py", line 72, in <module>
import Domoticz
ModuleNotFoundError: No module named 'Domoticz'

I did install plugin.py as written with the pip3 command (sudo pip3 install -r requirements.txt).
Now I have no ideas left, but still no Nibe values are shown in Domoticz :oops: :cry:

Thanks in advance for help!!!
Nibe F1255-6 PC heatpump, SolarEdge SE7K inverter + 16 x Solarwatt panels (in-roof 275Wp) + 12 x AEG panels 325Wp+ optimizers, EtaSunPro vacuum collector (60 tubes)
User avatar
waltervl
Posts: 5736
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: ModuleNotFoundError Python

Post by waltervl »

Please post the error you get in the Domoticz log (menu setup - log). Running a plugin outside Domoticz will give the error module not found because there is no Domoticz...

So what is the error you get when the plugin runs within Domoticz?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
moi427
Posts: 17
Joined: Tuesday 06 March 2018 11:24
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Contact:

Re: ModuleNotFoundError Python

Post by moi427 »

I can't see any message concering this in the Domoticz log (looking via Windows in the log). Before I tried installing flopp999/NIBEUplink-Domoticz I got a mail each 5 minutes, but that stopped. I guess I haven't installed this flopp999/NIBEUplink-Domoticz into Domoticz, but for me the description isn't that complete how I have to do that. So I guessed trying to run that plugin.py via Python would do the job to include the parameters at the proper place. apparently no, so how do I run or install flopp999/NIBEUplink-Domoticz into Domoticz? In Hardware NibeUplink show as it was since I installed the RCP a few years ago, but you can't add those parameters there.
I guess it's stupid, sorry for that.
Nibe F1255-6 PC heatpump, SolarEdge SE7K inverter + 16 x Solarwatt panels (in-roof 275Wp) + 12 x AEG panels 325Wp+ optimizers, EtaSunPro vacuum collector (60 tubes)
User avatar
waltervl
Posts: 5736
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: ModuleNotFoundError Python

Post by waltervl »

for nibe oplink plugin check this thread: https://domoticz.com/forum/viewtopic.php?p=287130

And if you want to use the flopp plugin check https://github.com/flopp999/NIBEUplink-Domoticz
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
moi427
Posts: 17
Joined: Tuesday 06 March 2018 11:24
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Contact:

Re: ModuleNotFoundError Python

Post by moi427 »

I read the text about the flopp plugin many times, but after getting a new access code plus having the others it's not clear to me where to put them. So that's the problem it seems. The first link was also already read a few times but neither of them provides me with "the solution".

It seems I miss something in the story of flopp, plus looking at the source of plugin.py I can't see where to put the parameters like in the original RPC /home/pi/domoticz/scripts/NibeUplink/config.json.
So unfortunately I've no cluea how to correct all this (despite having read amongst others those links since a few days) and get it working, but I'll try to find a working image of before May 11th and see if hopefully NibeUplink will then work again.
Nibe F1255-6 PC heatpump, SolarEdge SE7K inverter + 16 x Solarwatt panels (in-roof 275Wp) + 12 x AEG panels 325Wp+ optimizers, EtaSunPro vacuum collector (60 tubes)
User avatar
waltervl
Posts: 5736
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: ModuleNotFoundError Python

Post by waltervl »

Perhaps ask your question in the NIBE upload forum topic and someone with that plugin or flopp himself can help you.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
moi427
Posts: 17
Joined: Tuesday 06 March 2018 11:24
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Contact:

Re: ModuleNotFoundError Python

Post by moi427 »

Since this problem was not solvable (or at least not by me), I've restored an RPi image from before the start of the problems at 11-05-2022 (May 11th). Domoticz now works properly again as it did with my Nibe F1255PC via the NibeUplink RPC plugin, so I won't update Domoticz, Python or whatever without having a most recent working image at hand in case again this problem happens. So when the red F1255 sensors appear again with a date "last seen" older than one or two days, I'll restore that again.

A pitty I couldn't get the flopp999/NIBEUplink-Domoticz working, not knowing where to put the parameters etc. Anyway, it didn't work after having done everything exactly as written in the description. Also other descriptions of problems with python plugins didn't help me out of the problems, so now back to the older situation it works again to my great relief! But definitely a pitty updating caused all these problems, no idea what caused it although I wouldn't be supprised it's Python 3.10. :cry:
Nibe F1255-6 PC heatpump, SolarEdge SE7K inverter + 16 x Solarwatt panels (in-roof 275Wp) + 12 x AEG panels 325Wp+ optimizers, EtaSunPro vacuum collector (60 tubes)
Fdmekinabo
Posts: 3
Joined: Monday 10 June 2019 8:26
Target OS: -
Domoticz version:
Contact:

Re: ModuleNotFoundError Python

Post by Fdmekinabo »

I had a similar problem. It turned out. Python script was working ok via SSH, so as a pi user, but not via Domotics as root. Maybe the python or the module was installed not with the "sudo" command. My solution was to force domoticz to execute the script as a pi user. The script

script:///home/pi/voda60

was executed OK through Dzvents with the command in the events system:

domoticz. executeShellCommand("runuser -l pi -c /home/pi/voda60")
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest