Python modules suddenly failing with "ImportError: No module named personal"

  • Platform information:
    • Hardware: X86_64/32GB/500GB
    • OS: Ubuntu Server 18.04 LTS
    • Java Runtime Environment: zulu-8 Version: 8.36.0.1
    • openHAB version: 2.5.8-1
    • Jython-standalone 2.7.0
  • Issue of the topic: I’ve been developing some JSR233 Jython rules using a couple of Python modules I wrote and stored in openhab2/automation/lib/python/personal/ Had everything working quite nicely. Then I added a new module to openhab2/automation/lib/python/community and wrote up a rule to use that library, which left me running a two hour process I didn’t want to wait for to continue my debugging, so I stopped and restarted openhab.
    On restart, none of the scripts that are using my personal library modules are loading, with errors like:
[ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/python/personal/temperatures.py': ImportError: No module named personal in <script> at line number 12

It’s not even failing to find the specific module, it’s the whole “personal” directory it doesn’t seem to see any more. I’ve checked the directory permissions; no problem there.

It’s very bizarre.

scriptExtension.importPreset("RuleSimple")
scriptExtension.importPreset("RuleSupport")
scriptExtension.importPreset("RuleFactories")

from core.rules import rule
from core.triggers import when
from core.utils import sendCommand
import personal.heating
reload(personal.heating)
from personal.heating import decide_temperatures

I upgraded to Openhab 2.5.8-1 just after this started happening, with no change in behaviour.

Ah, figured it out. I accidentally deleted the __init__.py file from the personal folder!

1 Like