How can I use the Import statement to load a python module into a HABapp script?
I tried the example from the python tutorial - import the fibo.py module to another script
fibo.py to import
def fib(n): # write Fibonacci series up to n
a, b = 0, 1
while a < n:
print(a, end=' ')
a, b = b, a+b
print()
def fib2(n): # return Fibonacci series up to n
result = []
a, b = 0, 1
while a < n:
result.append(a)
a, b = b, a+b
return result
fibotest.py
import fibo
fibo.fib(1)
This looks good in pycharm, but in HABapp it fails:
2022-01-29 00:03:26.858 [ERROR] [HABApp.Rules ] - Error "No module named 'fibo'" in load:
2022-01-29 00:03:26.859 [ERROR] [HABApp.Rules ] - Could not load /etc/openhab/habapp/rules/testFibo.py!
2022-01-29 00:03:26.860 [ERROR] [HABApp.Rules ] - File "/opt/habapp/lib/python3.9/site-packages/HABApp/rule_manager/rule_file.py", line 80, in load
2022-01-29 00:03:26.860 [ERROR] [HABApp.Rules ] - self.create_rules(created_rules)
2022-01-29 00:03:26.861 [ERROR] [HABApp.Rules ] - File "/opt/habapp/lib/python3.9/site-packages/HABApp/rule_manager/rule_file.py", line 66, in create_rules
2022-01-29 00:03:26.861 [ERROR] [HABApp.Rules ] - runpy.run_path(str(self.path), run_name=str(self.path), init_globals={
2022-01-29 00:03:26.862 [ERROR] [HABApp.Rules ] - File "/usr/lib/python3.9/runpy.py", line 268, in run_path
2022-01-29 00:03:26.862 [ERROR] [HABApp.Rules ] - return _run_module_code(code, init_globals, run_name,
2022-01-29 00:03:26.863 [ERROR] [HABApp.Rules ] - File "/usr/lib/python3.9/runpy.py", line 97, in _run_module_code
2022-01-29 00:03:26.863 [ERROR] [HABApp.Rules ] - _run_code(code, mod_globals, init_globals,
2022-01-29 00:03:26.863 [ERROR] [HABApp.Rules ] - File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
2022-01-29 00:03:26.864 [ERROR] [HABApp.Rules ] - exec(code, run_globals)
2022-01-29 00:03:26.864 [ERROR] [HABApp.Rules ] - File "/etc/openhab/habapp/rules/testFibo.py", line 2, in testFibo.py
2022-01-29 00:03:26.865 [ERROR] [HABApp.Rules ] - 1 import HABApp
2022-01-29 00:03:26.865 [ERROR] [HABApp.Rules ] - --> 2 import fibo
2022-01-29 00:03:26.865 [ERROR] [HABApp.Rules ] - 3
2022-01-29 00:03:26.866 [ERROR] [HABApp.Rules ] - ..................................................
2022-01-29 00:03:26.866 [ERROR] [HABApp.Rules ] - HABApp = <module 'HABApp' from '/opt/habapp/lib/python3.9/site-packages/HABApp/__init__.py'>
2022-01-29 00:03:26.867 [ERROR] [HABApp.Rules ] - ..................................................
2022-01-29 00:03:26.867 [ERROR] [HABApp.Rules ] -
2022-01-29 00:03:26.867 [ERROR] [HABApp.Rules ] - ModuleNotFoundError: No module named 'fibo'
2022-01-29 00:03:26.871 [WARN ] [HABApp.Rules ] - Failed to load /etc/openhab/habapp/rules/testFibo.py!