Package import issue on Knime node built with Python

Hello,
I’m currently trying to build my own knime extensions from python code by following this post : https://www.knime.com/blog/4-steps-for-your-python-team-to-develop-knime-nodes.

Everything worked perfectly until the moment I wanted to import a package (called emd). Depending where I put the import it appears to have a different error.
For example if the import emd is at the begining of the code it looks like this follow and pop-up at the launch of Knime:


(python script + Knime Console)

If it’s imported inside the execute function it shows that :

I precise that I use my own anaconda environment and Knime (4.7) reads well other packages. I also precise that the emd package can be used in a Python Script node without any issue.

I really appreciate any help !

Cheers
Baptiste

Hi Baptiste,

I cannot reproduce it. For me the import emd works as expected.
Could you please provide the following?

  1. Crucial: the KNIME log file, especially the part where the Failed to parse Python... happens (View -> Open KNIME log); there are some essential details there
  2. A txt file with the content of conda list of your used environment
  3. Maybe the whole extension zipped

Best regards
Steffen

Hello Steffen,

As you wanted, I share you the full Knime Console output and the conda list. However, I seems that zip object can’t be shared on the forum (or am I that bad?).
knime_console.txt (1.8 MB)
conda_list.txt (332 Bytes)

Thanks for your help
Baptiste

Hi Baptiste,

ah yes, then maybe just upload the Python file (imf_sift.py?), if that’s not possible, transform it into a txt file.

For the knime log. The following shows that you import knime.scripting.io, which has no place there, you should delete that. That only belongs to Python Script nodes.

  File "C:\Users\bchaigneau\Desktop\Baptiste\Knime\Knime_extensions\imf_sift\tutorial_extension\imf_sift.py", line 3, in <module>
    import knime.scripting.io as knio
ModuleNotFoundError: No module named 'knime.scripting.io'

Does that already solve one or both issues? If not, please maybe send a knime log of the specific times again when the issues occur.

Best regards
Steffen

Oh sorry I didn’t see that Open KNIME log displays the whole error history. Some of them are not linked to my issue (like knio). I share you only the parts about it, and the python script associated.
knime_console.txt (17.2 KB)
python_imf_sift.txt (666 Bytes)

Thanks !
Baptiste

Hi Babtiste,

thanks for that! I still cannot reproduce it, even if I use your Python file.
If in the command line, you do conda activate <your_environment> and then conda list emd, does it show the following version and build?

# Name                    Version                   Build  Channel
emd                       0.4.0              pyhd8ed1ab_0    conda-forge

Could you provide the full content of conda list? Version numbers and so on.

Could you try other version of emd? Does it work with other Python packages?

Best regards
Steffen

Hi Babtiste,

you can ignore my previous comment. We can reproduce it and will look into it.

Best regards
Steffen

Oh ok !
I just tried to downgrade my emd 0.5.5 to 0.4 and it still don’t work. Also, I did some tests on others packages and everything worked well.

Thanks for your effort !
Baptiste

Hi Baptiste,

it could be that the logger handling of the emd package interferes with our logger handling.
I opened a ticket but it will not be solved in the upcoming KNIME Analytics Platform 4.7.1 release.

Best regards
Steffen

2 Likes

I see, that is unlucky but I’m really glad for your help. At least I know that the issue shouldn’t come from a wrong setup of my extension.
Thanks a lot !

Best regards,
Baptiste