I am calling a python script from OF that needs a few modules and I am running into problems. There isn’t any issue when running the script from terminal.
I’m calling my python script with ofSystem and the absolute path. At first it couldn’t find any of the imported modules. I found that explicitly setting search paths with the following in my .py helped resolve a couple of the issues.
But this doesn’t make a difference for importing other modules like portaudio (for example) even though it is also in the site-packages directory. It makes sense that portaudio would be different as it’s actually a c library being included via python. But I’m not sure how to resolve that! Any ideas?
I’m also having trouble importing the google cloud speech module.
I’ll try explicitly importing all the modules with their absolute paths next. But some of the modules are also including modules so I don’t think that will be the ultimate solution.
import importlib.util spec = importlib.util.spec_from_file_location("module.name", "/path/to/file.py") foo = importlib.util.module_from_spec(spec) spec.loader.exec_module(foo) foo.MyClass()