Python in KNIME (Anaconda style) for dummies

I just want to share something I struggled with before.
If you want to implement Python code in KNIME, the latter needs to read your environment, so you can import the libraries to work with.
Although there is a guide how to do it, it consists of so many steps, I just felt unnecessarily complicated. So here’s my quick guide how to use Python in KNIME (v. 3 only):

  1. Install Anaconda - it takes care of your environment, to ensure that different libraries which depend on each other are compatible. download

  2. Open your KNIME preferences, go to KNIME > Python and find your distribution path. In my case this is C:\ProgramData\Anaconda3 (on Win10x64). Choose your environment to be “base” and wait for it to be initialized (collected and tested).

  3. Start playing with Python:

You can define a variable to use in the code, so you can control multiple objects with one, as shown in the picture. You can play with the data frame as you wish, and importing and exporting the data is easy with double-clicking all the way. Note that there is probably a convention of in / out data table to be named as input_table and output_table.

While I’m not too advanced with Python, and haven’t run too complex flows with KNIME, this guide may be a good starting point of comprehending how the two software packages can work together. :slight_smile:
Cheers all!
Julian

9 Likes

Hi @deicide_bg,

new category on Forum - KNIME Resources, subcategory Knowledge sharing seems right for this topic so moving it!

Adding link to “unnecessarily complicated” but comprehensive Python installation guide in KNIME in case someone needs more info :wink:
https://docs.knime.com/latest/python_installation_guide/index.html

Tnx for sharing this!

Br,
Ivan

6 Likes