Search code examples
pythonpandasbokeh

ModuleNotFoundError: No module named 'bokeh.plotting.helpers' with bkcharts


I am trying to create a Scatter charts using bokeh in Jupyter Notebook version 6.0.3 but it's giving me ModuleNotFoundError: No module named 'bokeh.plotting.helpers' I have installed bokeh and bkcharts using pip install bokeh and pip install bkcharts.

Here is my code

from bkcharts import Scatter, output_file, show
import pandas

df=pandas.DataFrame(columns=["X","Y"])
df["X"]=[1,2,3,4,5]
df["Y"]=[5,6,4,5,3]


p=Scatter(df, x="X",y="Y", title="temperature observations", xlabel="Day", ylabel="Temp")

output_file("Scatter_charts.html")
show(p)

Solution

  • You should not use bkcharts for any reason. It was deprecated and removed from the main Bokeh project several years ago. It is abandoned and unmaintained. In order to use it today, you would also have to install an ancient Bokeh version 0.12.7 (or older).

    These days, anything you might want to do with bkcharts you can do just as well with the modern core Bokeh package.

    from bokeh.plotting import figure, output_file, show
    import pandas as pd
    
    df = pd.DataFrame(columns=["X","Y"])
    df["X"] = [1,2,3,4,5]
    df["Y"] = [5,6,4,5,3]
    
    p = figure(title="temp observations", x_axis_label="Day", y_axis_label="Temp")
    p.scatter(x="X", y="Y", source=df)
    
    output_file("scatter.html")
    show(p)
    

    If you want an even higher level API on top of Bokeh you could consider one of these more current third-party projects: