With the Python integration in KNIME you can use an existing Python installation from KNIME Analytics Platform. But what if Python is not yet installed on your system? Here is a quick step by step guide on how to install Python, get it working in KNIME, and also configure the Python Deep Learning extensions.
The KNIME Python and Deep Learning integrations are widely used. They contain Python based nodes to integrate Python versions 2 or 3 as well as Deep Learning nodes. For the purpose of this article, we’ll assume here that Python is not yet installed on your system.
1. Install the KNIME Python Integration
You’ll find the Python integration on the KNIME Hub. Enter Python in the search field and filter by Extensions. With your version of KNIME Analytics Platform open, drag the Python Integration download icon over to the Workflow Editor.
2. Install a KNIME Deep Learning Integration
If you want to use Python for deep learning, you will need to install one of the KNIME Deep Learning Integrations as well. You’ll find different deep learning integrations on the KNIME Hub, for example for Keras, TensorFlow, TensorFlow2, ONNX, etc. Choose the one(s) that you need for your project. Follow the same procedure as above to locate them on the Hub and install on your system.
3. Install Anaconda to Manage your Python Environments
Install Anaconda or Miniconda from the links below and choose the version of Python you prefer. We recommend using either the:
- Anaconda Python distribution from Continuum Analytics - the full toolkit to work with thousands of open source packages and libraries, or
- Miniconda - a minimal installer for conda, which includes only conda, Python, the packages they depend on, plus a small number of other useful packages.
4. Set Up your Python Environment
In your installation of KNIME Analytics Platform, go to the Preferences page under File menu. Under KNIME you'll find up to three Python-related options (based on the installed extensions): Python, Python Deep Learning, and Python Scripting. (Python Scripting is a community extension, which we won’t cover here in this article.)
Click the Python option to open the Python preferences.
Here, select Conda under Python environment configuration as shown in Figure 2.
Next, the page will specify a default Anaconda installation folder as per default installation (here). If you have installed Anaconda to a different location, provide the path to your Anaconda installation folder.
Once a valid path has been entered, you will see the conda version number shown on this page. Now choose which conda environment you want to use for Python 3 and Python 2 from the combo box.
If you have already set up a Python environment, containing all the necessary dependencies for the KNIME Python Integration, just select it from the list and you are ready to go. If you do not have a suitable environment available yet, click the New environment... button. This opens the following dialog (Figure 3):
Provide a name for the new environment and click the Create new environment button. This creates a new conda environment containing all the required dependencies for the KNIME Python Integration.
Once the environment is successfully created, the dialog closes and the new environment is selected automatically. If everything worked out fine, the Python version is now shown below the environment selection and you are ready to go.
After the environment is created, you can run Jupyter notebooks as well as the Python-based nodes such as Python scripting, Python Object Reader etc.
Example workflows that use the KNIME Python Integration
Here are two workflows that you can download and try out yourself if you want to try out using Jupyter Notebook in combination with KNIME.
5. Set Up your Python Deep Learning Environment
In your installation of KNIME Analytics Platform, go to the Preferences page in File menu. Under KNIME, click the Python Deep Learning option.
In the Python Deep Learning preferences (Figure 3) you have two options for configuring the Python Deep Learning environment.
Option 1: Use special deep learning configuration (recommended)
If you select this option, KNIME Deep Learning will use a different Python 3 environment to the one configured in the Python Preference page.
Similar to the Python preferences page, you can either automatically create Python 3 environments containing all required packages (by selecting the Conda sub option), or point to Python start scripts that activate a suitable environment you created manually (by selecting the Manual sub option).
If you have already set up a Python Deep Learning environment containing all the necessary dependencies for KNIME Deep Learning, just select it from the list and you are ready to go. If you do not have a suitable environment available, click the New environment… button. This opens the following dialog (Figure 5):
Option 2: Use Python configuration
If you choose this option, KNIME Deep Learning will use the same Python 3 environment as configured in the Python preference page. This assumes that this Python 3 environment already contains all required Python Deep Learning packages (which have to be installed manually).
A list of the required Python Deep Learning packages for the Keras Integration is documented in the KNIME Keras Integration Installation section. This option is intended for advanced users, we recommend choosing Option 1.
Example workflows that use the KNIME Deep Learning Integration
6. Install Additional Python Packages (optional)
The environment created using the Anaconda configuration only contains the packages as listed here. So, if you want to use Python packages other than the ones listed in the configuration files, these can be easily added manually after the environment has been created.
For example, if you want to use the scikit-learn package for data processing or ML based models in KNIME Python nodes, use the following command:
conda install --name <> scikit-learn
Wrap-up: Python-Related Resources at a Glance
This article was designed as a quick guide to not just installing and setting up the KNIME Python Integration and Deep Learning Integration for Python, but to give you some links to our favorite Python-related content on the KNIME website.
Workflows on KNIME Hub
- Run Jupyter in KNIME
- Using Jupyter from KNIME to embed document
- KNIME Deep Learning - Classify images using InceptionV3
- Sentiment Analysis with BERT
- COVID-19 Projections with KNIME, Jupyter, and Tableau by Dennis Ganzaroli
- Cutting Down Implementation Time by Integrating Jupyter and KNIME by Mahantesh Pattadkal
- Deploying Obscure Python Script: Neuro-Styling of Portrait Pictures by Rosaria Silipo and Mykhailo Lisovyi
- You don’t have to choose! Blending KNIME and Python by Greg Landrum
- BERT Text Classification for Everyone by Nadjet Bouayad-Agha & Artem Ryasik