Hub
  • Software
  • Blog
  • Forum
  • Events
  • Documentation
  • About KNIME
  • KNIME Hub
  • Nodes
  • Python Script (Labs)
NodeNode / Manipulator

Python Script (Labs)

KNIME Labs Python (Labs)
Drag & drop
Like
Copy short link

This node is currently part of KNIME Labs. It is not yet advised to use it in production. Please consider the following prerequisites and limitations before employing it:

  • Python 2 is not supported.
  • Additional packages, namely py4j and pyarrow , are required to be installed in your Python 3 environment in specific versions. We recommend to create a new Conda environment that contains these packages via File → Preferences → KNIME → Python.
  • Columnar Backend should be enabled for best performance.
  • Extension data types such as images from KNIME Image Processing or molecules from RDKit Nodes for KNIME are not supported yet.
  • The scripting API is under active development and may be subject to breaking changes in future releases until this node has been promoted from KNIME Labs.
The node brings significant performance improvements over the nodes of the stable KNIME Python Integration and enables working with larger-than-memory data. More details on how to transition to the node's new scripting API can be found here . There are also example workflows that further illustrate its use here as well as example templates on the Templates tab of the node.

The node allows executing a Python script in a local Python 3 environment. The environment has to be configured under File → Preferences → KNIME → Python or via flow variable, as described in the KNIME Python Integration Guide .
Multiple input and output ports of various types can dynamically be added to the node and used in the script. See sections Ports and Editor below for a description of all available inputs and outputs, and how they can be accessed in the Python script.
Furthermore, the node allows to import Jupyter notebooks as Python modules via the knime_jupyter module that can be imported in the script.

Node details

Input ports
  1. Type: Table
    Table
    No description available
Output ports
  1. Type: Table
    Table
    No description available
Input object (pickled) (Dynamic Inport)
An input object. Input objects are automatically unpickled for you. You can access them via knio.input_objects . For example, the first input object can be accessed like this: knio.input_objects[0] .
  1. Type: Python
Input table (Dynamic Inport)
An input table. You can access input tables via knio.input_tables . For example, the first input table can be accessed like this: knio.input_tables[0] . Each table is an instance of type knime_table.ReadTable . Before being able to work with the table, you have to convert it into, for example, a pandas.DataFrame or a pyarrow.Table . Please refer to the KNIME Python Integration Guide to learn how to do this, or take a look at one of the templates on the Templates tab of the node.
  1. Type: Table
Output table (Dynamic Outport)
An output table. The table has to be populated via knio.output_tables in your script. For example, to populate the first output table, assign it a value like this: knio.ouput_tables[0] = <value> . The assigned value must be an instance of type knime_table.WriteTable which can be created from, for example, a pandas.DataFrame or a pyarrow.Table . Please refer to the KNIME Python Integration Guide to learn how to do this, or take a look at one of the templates on the Templates tab of the node.
  1. Type: Table
Output image (Dynamic Outport)
An output image. The image has to be populated via knio.output_images in your script. For example, to populate the first output image, assign it a value like this knio.output_images[0] = <value> . The assigned value must be either a string describing an SVG image or a byte array encoding a PNG image.
  1. Type: Image
Output object (pickled) (Dynamic Outport)
An output object. The object has to be populated via knio.output_objects . For example, to populate the first output object, assign it a value like this: knio.output_objects[0] = <value> . The assigned value can be of any type that can be pickled. It will automatically be pickled for you.
  1. Type: Python

Extension

The Python Script (Labs) node is part of this extension:

  1. Go to item

Related workflows & nodes

  1. Go to item
    Python Script example with new Python API backend
    Python Scripting Columnar backend
    This workflow uses the new Python Script node. This node features a new backend that make…
    knime > Examples > 07_Scripting > 03_Python > 07_Python_Script_example
  2. Go to item
    KNIME forum (44928) - PyArrow, Batch, URL
    Python Pyarrow
    KNIME forum (44928) - PyArrow, Batch, URL
    mlauber71 > Forum > 2022 > kn_forum_44928_pyarrow_batch_url_import
  3. Go to item
    Read binary Excel Files (.xlsb) wit the help of Python package "pyxlsb"
    Python Excel Xlsb
    +3
    Read binary Excel Files (.xlsb) wit the help of Python package "pyxlsb" conda install -c …
    mlauber71 > Public > kn_example_python_excel_xlsb
  4. Go to item
    KNIME_challenge20_solution
    Justknimeit Justknimeit-20
    Challenge 20: Patient Network Days
    martinmunch > Public > KNIME_challenge20_solution
  5. Go to item
    Python Performance
    mpattadkal > Public > Python Performance > Python Performance
  6. Go to item
    KNIME/Python - write and read back a dictionary
    Python Knime Pickle
    +5
    KNIME/Python - write and read back a dictionary Pickle any Python object you want, save i…
    mlauber71 > Public > kn_example_python_pickle_dictionary
  7. Go to item
    Loop_Python_Script_Labs_Benchmark
    tymsk3891 > Public > tmp > Loop_Python_Script_Labs_Benchmark
  8. Go to item
    KNIME and Python - handle index columns and row_id
    Knime Python Rowid
    +3
    KNIME and Python - handle index columns and row_id Python script would convert the KNIME …
    mlauber71 > Public > kn_example_python_index_rowid
  9. Go to item
    use a component to create individual python code dynamically in a sub-folder
    Pythpn Knime Py
    +3
    use a component to create individual python code dynamically in a sub-folder ... well adm…
    mlauber71 > Public > kn_example_python_component_py_module
  10. Go to item
    Try to import EDIFACT files with Python package "pydifact"
    Python EDIFACT Parse
    Try to import EDIFACT files with Python package "pydifact"
    mlauber71 > Forum > 2022 > kn_forum_39612_python_edifact_parse

No known nodes available

KNIME
Open for Innovation

KNIME AG
Hardturmstrasse 66
8005 Zurich, Switzerland
  • Software
  • Getting started
  • Documentation
  • E-Learning course
  • Solutions
  • KNIME Hub
  • KNIME Forum
  • Blog
  • Events
  • Partner
  • Developers
  • KNIME Home
  • KNIME Open Source Story
  • Careers
  • Contact us
Download KNIME Analytics Platform Read more on KNIME Server
© 2022 KNIME AG. All rights reserved.
  • Trademarks
  • Imprint
  • Privacy
  • Terms & Conditions
  • Credits