Skip to content
KNIME Documentation
Main Navigation Get startedBuildWork with KnimeAccount and adminRelease notesDeveloper tools
Community Hub
DevelopersKnime
Sidebar Navigation

Getting Started

Installation

User Guide

Release Notes

Install Extensions

Building Workflows

Components

Flow Control

Expressions

File Handling

Deployment

Integrated Deployment

Workflow Invocation

Best Practices

Advanced Features

AI Extension

Get Started

Build an Agent

Inject context with RAG

LLM Providers

Tutorials

Summarize product reviews

Product FAQ assistant

Restaurant agent

Your first local agent

Task extractor

Reporting

Kerberos

Extensions

Database

Overview

Tutorials

Read and filter data from a database

Write a transformed dataset to a database

Concepts

Ports and Sessions

Query Generation

Type Mapping

Deprecated Framework

Connecting

Connect: Dedicated Node

Connect: File-Based Database

Connect: Generic DB Connector

Register a JDBC Driver

Install Third-Party Driver Plug-in

Drivers on Hub and Server

Kerberos Constrained Delegation

Reading and Transforming

Read Data

Transform Data Visually

Run a Custom SQL Query

Parameterize a Query

Writing and Modifying

Insert, Update, or Merge

Delete Rows

Bulk Load Data

Create and Remove Tables

Use Transactions

Reference

Connector Node Settings

JDBC Driver Reference

Deprecated Node Mapping

Migrate Deprecated Workflows

Python

Overview

Tutorials

Python Scripting Quickstart

Data App Development Using Plotly

Data Processing

K-AI Scripting Assistant

Data Type Conversion

Batch Processing

Jupyter Integration

Environment Management

Pixi Configuration

Dependency Management

Environment Persistence

Channel Mirrors & Air-Gapped Setups

Conda Migration

Alternative Configurations

Conda and Miniforge Setup

Conda Environment Propagation

Manual Python Configuration

Legacy Node Migration

Concepts

Pixi Backend Architecture

Storage Logic

Python Environments on Executors

Reference

Python Scripting API

Bundled Packages

Executor and Hub Configuration

Troubleshooting Guide

API Reference

Inputs and outputs

Classes

Views

Utility functions

R

Deep Learning

Snowflake

Google Cloud

Azure

AWS

Big Data

Big Data Admin

Big Data Secured Cluster

Databricks

Microsoft Fabric

Power BI

Tableau

Report Designer

H2O

Changelogs

Version 5.12

Version 5.11

Version 5.10

Version 5.9

Version 5.8

Version 5.7

Version 5.6

Version 5.5

Version 5.3

Extensions

Initialize a Custom Python Environment and Build an Interactive Data App Using Plotly ​

This tutorial covers how to initialize a custom Python environment with additional packages that are not included in the bundled environment, and how to transform a Plotly visualization into a functional Data App using the Python View node. You will learn how to embed Plotly charts, connect Widgets for interactivity, and deploy the result to the KNIME Hub.

Objective ​

Create an animated map that displays global life expectancy trends. The app uses a custom Python environment for the visualization and KNIME nodes for the interface and deployment.

What you need ​

  • KNIME Analytics Platform: Download and install the latest version.
  • KNIME Hub account for deployment. Checkout KNIME offering here.

Step 1. Download the Example Workflow ​

  1. Visit the Interactive Python Data App workflow on the KNIME Hub.
  2. Click Download to save the workflow file (.knwf).
  3. Import the file into your Local Workspace and open it.

Step 2. Configure the Python Environment ​

The Plotly package is not part of the bundled environment. The Python Environment Provider node manages all the background setup for a customized environment for you.

  1. Open the Python Environment Provider node configuration.
  2. Add plotly to the Additional dependencies list.
  3. Click Resolve dependencies and wait for the green status indicator.
  4. Click Apply and execute.

TIP

To see which libraries are already included in the default environment, check the KNIME Anaconda channel.

Step 3. Write the Visualization Script ​

  1. Open the Python View node editor.
  2. Use the following script to render the chart and send it to the KNIME interface via knio.output_view.
python
import knime.scripting.io as knio
import plotly.express as px

# 1. Load dataset
df = px.data.gapminder()

# 2. Define animated map
fig = px.choropleth(
    df,
    locations="iso_alpha",
    color="lifeExp",
    hover_name="country",
    color_continuous_scale=px.colors.sequential.Plasma,
    scope="world",
    animation_frame="year"
)

fig.update_layout(
    title="Life Expectancy: World View",
    margin={"r":0,"t":50,"l":0,"b":0},
    height=700
)

# 3. Output the view
knio.output_view = knio.view(fig)
  1. Execute the node and check the Interactive View to confirm the map renders.

Step 4. Add Interactivity with Widgets ​

Connect selection widgets to control the map parameters.

  1. Selection: Use the Single Selection Widget (pre-configured with regions).
  2. Connection: Link the red flow variable ports from the widgets to the Python View node.

Step 5. Connect Variables to Python ​

Update the script to use the widget output.

  1. Locate the map_scope variable in the Flow Variables tab.
  2. Replace the static scope value in your script:
python
# Use the flow variable for the scope parameter
fig = px.choropleth(
    df,
    # ...
    scope=knio.flow_variables["map-scope"],
)

Step 6. Define the Data App Layout ​

  1. Create Component: Select the Widgets and the Python View node. Right-click the selection and select Create Component.
  2. Open Layout Editor: Right-click the Component, then go to Component > Open Layout Editor.
  3. Arrange Elements: Drag the nodes into the grid to define the visual interface for the browser.

Layout Editor setup

Step 7. Deploy to KNIME Hub ​

  1. Upload: Right-click the workflow in the Explorer > Upload. Select a space you have access to.
  2. Create a version: Open the workflow on the Hub website. Click the Versions button and create a version.
  3. Create Deployment: Click Deployments and select Create Data App.
  4. Select Data App: Choose the Data App option to generate a web URL.
  5. Run and Share: Execute the app from the Deployments section or use the "three dots" menu to share the URL with other users.

Final Result ​

The map is now accessible via a browser. Users can filter by region and animate the data by year using the interface you designed.

Data App in browser

Next steps ​

  • Data Apps for Beginners: Technical guide for building and sharing applications on the KNIME Community Hub.
  • Enroll in the 30-minute course: Take the free, hands-on LearnUpon course to solidify your new skills in building Data Apps.
Pager
Previous pagePython Scripting Quickstart
Next pageK-AI Scripting Assistant