Environment Setup
Before plotting anything, you need Bokeh installed in a clean Python environment. Bokeh 3.x supports Python 3.10 or later and has few required dependencies, so installation is quick. The recommended arrangement is a virtual environment dedicated to the project, which keeps Bokeh versions from clashing with other visualization libraries.
Installing Bokeh
Install with pip or conda:
pip install bokeh
or, if you use Anaconda:
conda install bokeh
Verify the installation by printing the version from Python:
import bokeh
print(bokeh.__version__) # e.g. 3.4.0
Anything at or above 3.0 is fine for this tutorial; older 2.x code uses slightly different signatures for some properties, so avoid mixing versions.
Creating a Virtual Environment
python3 -m venv bokeh-env
source bokeh-env/bin/activate
pip install bokeh pandas numpy jupyter
Pandas and NumPy are not hard dependencies for standalone plotting, but nearly every real workflow passes DataFrames or arrays to a ColumnDataSource, so install them together.
Checking the Samples
Bokeh ships a gallery of example apps. Running one confirms both the library and the Bokeh Server work:
bokeh sampledata
bokeh serve --show examples/app/sliders.py
The first command downloads optional sample datasets such as periodic_table and glucose. The second starts a local server and opens the sliders dashboard in your browser at http://localhost:5006/sliders.
Development Workflow
A typical setup uses three artifacts:
- a virtual environment with bokeh, pandas, and numpy
- a scratch notebook or script for quick figure experiments with
show(p) - an application module such as
app.pywhose root is thecurdoc()document, served withbokeh serve app.py
For standalone HTML output, calling show() on a figure writes a file next to the script and opens the default browser, so no web framework is required to preview results.
Common Installation Issues
- Old Bokeh at import time — the active environment may not be the one you installed into. Run
pip show bokehand check the Location, or usepython -m pip install bokehinside the environment. - Port already in use — Bokeh Server defaults to port 5006. Start it on another port with
bokeh serve app.py --port 5007. - Blank plots in the browser — verify BokehJS actually loaded; when you use
bokeh.embedmanually you must either reference the CDN or install local static resources withbokeh.resources.
Summary
Install Bokeh in a dedicated virtual environment with pandas and numpy, confirm the version with bokeh.__version__, and exercise the bundled sample apps to validate both standalone rendering and the Bokeh Server before writing your first figure.