Header Ads Widget

⚡ Premium Tools Hub • EXE Apps + Full Python Source Code
Lite • Pro • Bundle Packs • Instant Download

Bokeh Subcommands: A Complete Guide to Managing Bokeh Applications from the Command Line

Bokeh is not only a powerful Python visualization library but also provides a convenient command-line interface (CLI) for managing visualization workflows. Through Bokeh Subcommands, developers can quickly launch applications, generate standalone HTML files, inspect configurations, export resources, and manage interactive dashboards directly from the terminal.

Understanding Bokeh Subcommands is essential for developers who work with interactive dashboards, data visualization applications, and production-ready web analytics systems. These commands simplify development workflows and make it easier to test, share, and deploy Bokeh projects.

In this tutorial, you will learn how Bokeh Subcommands work, explore commonly used commands, understand their options, and discover best practices for managing professional Bokeh applications.


What Are Bokeh Subcommands?

Bokeh Subcommands are command-line tools included with the Bokeh package that allow developers to perform common tasks without writing additional Python scripts.

They provide access to features such as:

  • Running Bokeh Server applications
  • Creating HTML visualizations
  • Exporting charts
  • Managing resources
  • Generating examples
  • Checking installation information
  • Supporting development workflows

Instead of manually configuring applications, developers can use simple terminal commands to control Bokeh projects.


Installing Bokeh

Before using Bokeh commands, install the library.

pip install bokeh

Check your installation:

bokeh info

This command displays useful information including:

  • Bokeh version
  • Python version
  • Installed dependencies
  • Environment details

Viewing Available Bokeh Commands

To see available commands:

bokeh --help

The help menu displays available subcommands and options.

Common commands include:

  • serve
  • html
  • info
  • sampledata
  • secret
  • static

Bokeh Serve Command

The most commonly used Bokeh subcommand is:

bokeh serve

It launches a Bokeh Server application.

Example:

bokeh serve app.py

This starts an interactive application accessible through a web browser.

Example URL:

http://localhost:5006/app

The serve command is used for applications requiring:

  • Python callbacks
  • Live updates
  • Interactive widgets
  • Real-time data
  • User sessions

Running Multiple Applications

You can run multiple Bokeh applications together.

Example:

bokeh serve dashboard.py analytics.py

This creates separate application endpoints.

Multiple applications are useful for:

  • Business dashboards
  • Internal tools
  • Analytics platforms
  • Research applications

Using the Serve Command Options

Bokeh Server provides many configuration options.

Example:

bokeh serve app.py --show

The --show option automatically opens the application in your browser.

Other useful options include:

--port
--address
--allow-websocket-origin
--num-procs

Setting a Custom Port

By default, Bokeh Server runs on port 5006.

You can change it:

bokeh serve app.py --port 8080

This is useful when:

  • Another service uses the default port
  • Deploying multiple applications
  • Running in production environments

Opening Applications Automatically

Use:

bokeh serve app.py --show

This automatically launches your default browser.

It is convenient during development and testing.


Bokeh HTML Command

The HTML command creates standalone HTML documents.

Example:

bokeh html script.py

It converts Python visualization code into a shareable HTML file.

Standalone HTML files:

  • Do not require a server
  • Can be opened offline
  • Are easy to share
  • Work in modern browsers

Exporting Visualizations

You can export Bokeh charts into HTML format.

Example Python file:

from bokeh.plotting import figure, output_file, save

plot = figure()

plot.circle(
    [1,2,3],
    [4,6,8]
)

output_file("chart.html")

save(plot)

The result is a standalone visualization.


Bokeh Info Command

The info command provides environment details.

Run:

bokeh info

It displays:

  • Installed Bokeh version
  • Python environment
  • Browser support information
  • Dependency versions

This is useful for debugging installation problems.


Bokeh Sampledata Command

Bokeh includes sample datasets for learning and testing.

Install sample data:

bokeh sampledata

Sample datasets are useful for:

  • Tutorials
  • Experiments
  • Testing dashboards
  • Learning visualization techniques

Bokeh Static Command

The static command manages static resources.

Static resources include:

  • JavaScript files
  • CSS files
  • Bokeh libraries
  • Frontend assets

This is useful for advanced deployments where applications require customized resource handling.


Using Bokeh Commands in Development

A typical workflow:

Step 1: Create Application

Create Python visualization code.

Example:

app.py

Step 2: Test Application

Run:

bokeh serve app.py --show

Step 3: Modify Code

Update:

  • Charts
  • Widgets
  • Callbacks
  • Data sources

Step 4: Deploy

Configure:

  • Server settings
  • Security
  • Reverse proxy
  • Hosting environment

Bokeh Subcommands and Jupyter

Bokeh commands work well with Jupyter workflows.

You can:

  • Develop charts in notebooks
  • Export visualizations
  • Move applications into server environments
  • Test interactive features

This makes Bokeh suitable for both data science and software development.


Common Bokeh CLI Options

Some frequently used options:

Show Browser

--show

Automatically opens the application.

Port Selection

--port

Changes the server port.

Debug Mode

--log-level debug

Provides detailed logging.

Multiple Processes

--num-procs

Runs multiple worker processes.


Deploying Bokeh Applications

Bokeh applications can be deployed using:

  • Cloud servers
  • Docker containers
  • Virtual machines
  • Internal company servers
  • Data science platforms

Production deployment usually requires:

  • Reverse proxy configuration
  • HTTPS security
  • Authentication
  • Performance monitoring

Best Practices

When using Bokeh Subcommands:

  • Use meaningful application filenames.
  • Test applications locally before deployment.
  • Use version-controlled projects.
  • Document CLI commands.
  • Monitor server performance.
  • Keep Bokeh updated.
  • Secure production applications.

These practices make development and maintenance easier.


Common Mistakes

Avoid these issues:

  • Running outdated Bokeh versions.
  • Forgetting required dependencies.
  • Using incorrect ports.
  • Deploying without security settings.
  • Ignoring browser compatibility.
  • Creating unnecessary server processes.

Proper command usage prevents common deployment problems.


Real-World Applications

Bokeh Subcommands are useful for:

  • Interactive business dashboards
  • Financial analytics systems
  • Scientific visualization tools
  • Machine learning interfaces
  • IoT monitoring platforms
  • Educational applications
  • Data exploration portals

They simplify the management of professional visualization solutions.


Advantages of Using Bokeh CLI

Using Bokeh Subcommands provides:

  • Faster development workflow
  • Simple application launching
  • Easier debugging
  • Efficient deployment
  • Better project management
  • Improved productivity

Command-line tools help developers focus more on building applications rather than managing setup tasks.


Conclusion

Bokeh Subcommands provide a powerful and efficient way to manage Python visualization projects from the command line. With commands such as serve, html, info, sampledata, and static, developers can quickly create, test, export, and deploy interactive applications.

Whether you are developing dashboards, scientific tools, financial applications, or real-time analytics platforms, mastering Bokeh Subcommands will improve your workflow and help you build professional interactive visualization solutions more efficiently.

A Complete Guide to Managing Bokeh Applications from the Command Line


Post a Comment

0 Comments