If you want to make visualizations using Bokeh or try out some of the code examples in this tutorial, you will need access to a Python installation and to the Bokeh package (version 3.0 or greater), along with a few other packages from the Python ecosystem that we make use of (Pandas, NumPy, and also Jupyter if you'd like to run the code in a notebook). This can be accomplished in various ways:

  • having a Python installation, along with Bokeh and other necessary packages, on your local system
  • running on an online webserver or other compute resource that serves up Jupyter notebooks (e.g., Google Colaboratory, AWS SageMaker Studio Lab, the TACC Analysis portal)
  • having access to a remote machine or cluster that has all the relevant software installed

Regardless of whichever scenario you choose, it is possible that all the relevant packages are already installed and available for import within Python. The Anaconda Distribution, for example, contains a large bundle of Python packages by default, including Bokeh, Pandas, NumPy, etc. Many popular packages are also typically installed on publicly available Jupyter notebook servers. If you are running in a Jupyter notebook, you will want to configure the output to render within the notebook, as described in Uses & Capabilities.

If the packages you need are not pre-installed, or if you are instead using a more minimal distribution and building customized environments (either conda environments as part of a miniconda installation, or Python virtual environments that use pip for package installation), then you can follow the instructions below for more information on installing the relevant packages.

In the first scenario above (running locally), you should be able to display standalone Bokeh-generated visualizations to your browser or notebook environment easily. You should also be able to run the Bokeh server examples by running the appropriate command from a shell command line.

In the second scenario (running on some sort of Jupyter notebook server), you should be able to display standalone Bokeh-generated visualizations within the notebook environment easily. We do not know what might be required in order to run Bokeh server code in such an environment.

In the third scenario (having access to a remote machine or cluster), using Bokeh might be either more restrictive or more complicated to set up. You could certainly use the Bokeh API in a program running on a remote machine to process data and to generate standalone HTML files, much in the same way that you can use Matplotlib with a non-interactive backend to generate and save image files on a remote resource. Those generated files could then be transferred back to your local system for further use. Alternatively, it might be possible to set up an SSH tunnel, whereby a Bokeh server is running on the remote resource that you can connect to as if it were your browser's localhost, as described in the Bokeh documentation on Deployment scenarios.

Installing bokeh and other packages

Many Python installations can co-exist on a single machine, and many different virtual environments can be set up to isolate different package installations and versions. You can always type which python within a Linux/Mac/Unix command shell to learn which version of python is first in your shell path. Assuming that your path is configured to point correctly to the version/installation you want to run, you can easily check whether bokeh is installed by executing in the shell the following command that attempts to import the bokeh module:

If you don't see any error messages, bokeh is installed and was able to be imported.

conda

If you are running a conda-based Python installation (e.g., miniconda, or the Anaconda Distribution), then you can customize environments as you see fit. The full Anaconda Distribution installs by default a large number of packages useful for data science and scientific computing in Python, and Bokeh is part of that collection. But managing one large environment to accommodate all your needs can be complicated, and it is often better to set up your own tailored conda environments containing just those packages you need for a specific task or project. You can create new environments containing those packages you need uing the conda package manager. If you just want Bokeh, its dependencies, and the other packages that you need to run the code examples contained here, you could execute commands like this to create and activate a new environment named bokeh_and_friends:

pip

If you are running a non-conda-based Python installation, you can create Python virtual environments (similar to the conda environments discussed above) and use the pip package manager to install those packages you need in your environments. To create, activate, and populate a Python virtual environment named bokeh_and_friends, you could run something like the commands below to install that environment in your current working directory. Note that a Python virtual environment requires an existing Python installation to bootstrap the process with, whereas the conda environment created above can bring in a specific Python version as part of the environment creation itself.

Running Bokeh

If you are using Bokeh to generate standalone plots (either in HTML files, or rendered within Jupyter notebooks), then you don't "run" Bokeh. Instead, as with any other Python program, you import whatever parts of the Bokeh package you need for your particular application and run that program within a python, ipython, or jupyter/ipykernel interpreter.

If you are using Bokeh server (either on your local system through your browser's localhost address, or on a webserver accessible through the Internet), then you do in fact "run" Bokeh using the bokeh command-line utility that should be accessible in your path on the command line as part of a Bokeh installation. As described in more detail in our material on Bokeh server, you can run a Python program configured to be served up with bokeh with a command like this (assuming your program is named myapp.py):

 
©   Cornell University  |  Center for Advanced Computing  |  Copyright Statement  |  Inclusivity Statement