How to install bokeh for Python3

12,271

Solution 1

It will sound trivial but you need to install both (jupyter notebook and bokeh) under the same environment (virtual or not).

If you installed jupyter notebook using a snippet from the jupyter's website (pip3 install jupyter) then you have it installed in a non-virtual environment and from what I've understood you are trying to import bokeh which is installed in a virtual one.

There are two solutions:

  1. You run everything under non-virtual environment (which is probably not the best/cleanest choice):

    • install the notebook using pip3 install jupyter
    • install bokeh using pip3 install bokeh
    • start the notebook using jupyter notebook (without activating virtual environment)
  2. You run everything under virtual environment:

    • activate your virtual environment
    • install the notebook using python -m pip install jupyter
    • install bokeh using python -m pip install bokeh
    • start the notebook using jupyter notebook

Solution 2

I had the same problem here. Apparently, there are some problems with pip installation. I solved my problem with re-installing bokeh with conda.

Solution 3

You can have both versions of pip together (pip2, pip3).

Also pip can be linked to whether pip2/python2 or pip3/python3.

For me, pip is linked to the Python 3.x, pip2 to the Python 2.7 and pip3 to the Python 3.x:

$ pip -V
pip 9.0.3 from /usr/local/lib/python3.6/dist-packages/pip-9.0.3-py3.6.egg (python 3.6)

$ pip2 -V
pip 10.0.1 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)

$ pip3 -V
pip 9.0.3 from /usr/local/lib/python3.6/dist-packages/pip-9.0.3-py3.6.egg (python 3.6)

Python versions:

$ python -V
Python 2.7.12

$ python3 -V
Python 3.6.6

In this case, you should install bokeh for both versions of Python:

pip3 install bokeh
pip2 install bokeh

Test:

$ python
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import bokeh
>>> 

$ python3
Python 3.6.6 (default, Jun 28 2018, 04:42:43) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import bokeh
>>> 

[NOTE]:

Refer to the following links to install both versions of pip:

Share:
12,271

Related videos on Youtube

Violet
Author by

Violet

in debugging mode..

Updated on June 04, 2022

Comments

  • Violet
    Violet almost 2 years

    I installed bokeh via pip and here is the information of the versions that are installed

    pooja@X1-Carbon-6:~$ python3 --version
    Python 3.5.2
    pooja@X1-Carbon-6:~$ python --version
    Python 2.7.12
    pooja@X1-Carbon-6:~$ bokeh --version
    0.13.0
    

    for python2, it works fine and could import bokeh

    lkhr@X1-Carbon-6:~notebooks$ python
    Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
    [GCC 5.4.0 20160609] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import bokeh
    >>> 
    

    However, it complains when I use python3

    olkhr@X1-Carbon-6:~$ python3
    Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
    [GCC 5.4.0 20160609] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import bokeh
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ImportError: No module named 'bokeh'
    >>> 
    

    I want to use bokeh in my Python3 Jupyter-Notebook and having problem cos of this, if any suggestions are available, please let me know.

    Many thanks,

    • Violet
      Violet over 5 years
      I could install bokeh on virtual python3 environment, could do 'bokeh import' in python3, but still fail to import it in python3 jupyter-notebook, when opened in python3 virtual environment. (disappointed)
    • Benyamin Jafari - aGn
      Benyamin Jafari - aGn over 5 years
      I posted an answer, hope help you up
  • Violet
    Violet over 5 years
    Thanks for sharing your experiences. I am personally not a big fan of conda cos of my past experiences. So would like to have things working without conda. Lets see, if I succeed or would have to give Conda a try again. thanks again!
  • Ashkan Farhadi
    Ashkan Farhadi over 5 years
    @Pooja If you succeed, please let us know how. Thank you.
  • bigreddot
    bigreddot over 5 years
    @Pooja I'd encourage you to look at conda again. All conda environments are completely self-contained and don't touch the system or other Python at all, which is a great feature for safety and reproducibility. Additionally many of the packages shipped with conda are more optimized (e.g. NumPy ships with Intel MKL linked)