Search code examples
pythonbokeh

ModuleNotFoundError: No module named 'bokeh'


I've tried changing PATHs, pip install, pip env. I don't know what else to try and it's getting frustrating.

/usr/local/bin/python3 
 % /usr/local/bin/python3 
Traceback (most recent call last):
 line 1, in <module>
    from bokeh.plotting import figure, output_file, show
ModuleNotFoundError: No module named 'bokeh'
(base) ~ % 

I have both python2 and python3 installed.


Solution

  • Your question seems to be quite general. If it is related to set up a virtual environment you can do the following using venv in Linux.

    # create and go to a project folder
    $ mkdir project_folder
    $ cd project_folder
    
    # make a python virtual environment and activate
    $ python -m venv ./venv
    $ source ./venv/bin/activate
    
    # then pip install modules you need, for example numpy
    (venv)$ pip install numpy
    
    # check in a repl if you can import
    (venv)$ python
    >>>import numpy as np
    >>>np.arange(1, 10, 2)
    >>>
    
    # to leave the virtual environment 
    (venv)$ deactivate
    $
    

    See Virtual Environments and Packages. If you use Windows I recommend to use Anaconda for installing packages and organize your Python environment.

    If you want information on Bokeh there is a nice tuturial from Real Python Interactive Data Visualization in Python With Bokeh.