I am struggling to connect my pure-Python extension running on Python 3.11 and conda 23.5.2 with my KAP v4.7 in debug mode.
This is an excerpt of my extension’s folder structure:
When starting KAP, it throws this exception:
ERROR PurePythonNodeSetFactory Failed to parse Python node extension at path 'path/to/KNIME/test_extension'.
‘path/to/KNIME/test_extension’ is the path specified in my config.yml’s src key-value pair.
The KNIME logs show that this is due to the following problem of importlib:
ModuleNotFoundError: No module named 'test_nodes.py'; 'test_nodes' is not a package
‘test_nodes.py’ is the value assigned to the extension_module key in knime.yml.
The error persists despite having added the KNIME and KNIME/test_extension folders (with and without empty __init__.py files) to sys.path of my conda environment ‘knime_dev’ (as per conda_env_path in config.yml) via either of the following methods:
- a .pth file in ./opt/miniconda3/envs/knime_dev/lib/python3.11/site-packages
- putting the entire project folder in ./opt/miniconda3/envs/knime_dev/lib/python3.11/site-packages
What am I missing here to point KNIME to my test_nodes.py file?
The information that I am sharing with you above are from a Mac, but I face the exact same issue on Windows too. So, I am looking to fix this on both systems. Please note that I do not have admin rights on the Windows machine.
@DerMaxdorfer I can offer this example how to import one’s own module. Maybe you can test and take it from there:
Thanks for the example workflow, @mlauber71. I appreciate your support on the weekend!
Your call to sys.path.append() is basically the same as me adding a .pth file to a conda env, with the following two differences:
- Paths listed in a .pth file are available from the startup of the Python instance
- Paths are not removed after the script has finished running
The question that remains for me is which is the correct path to append to sys.path so that KAP finds the .py file with my nodes?
As my case is not with a particular workflow and Python Script nodes, but an entire extension, I do not have a workflow directory because KAP runs in to the described error before I even get the chance to open a workflow.
it looks like KAP already knows of the existence of your extension and where to find it.
I suspect that
knime.yml is not pointing correctly to
- Provide the line
extension_module in your
- Verify that it looks like this:
- Have another look at the setup of
- If the issue persists: provide the whole section of the
KNIME Log regarding the issue
You are spot-on, @steffen_KNIME!
I had it like this in my file:
extension_module: test_nodes.py. It is pretty obvious now that this key-value pair does not take the filename extension given that you even named the key extension_module and not extension_file. I must have overlooked it in the documentation because
license_file seem to require their respective ones indeed.
And it is not necessary to append anything to sys.path myself. KNIME is smart enough to find the extension anywhere on my machine.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.