2

我通过 pip 安装了散景,这里是已安装版本的信息

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

对于python2,它工作正常并且可以导入散景

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
>>> 

但是,当我使用 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'
>>> 

我想在我的Python3 Jupyter-Notebook中使用散景并遇到问题,如果有任何建议,请告诉我。

非常感谢,

4

3 回答 3

3

这听起来微不足道,但您需要在同一环境(虚拟或非虚拟)下安装两者(jupyter notebook 和 bokeh)。

如果您使用jupyter网站pip3 install jupyter

有两种解决方案:

  1. 您在非虚拟环境下运行所有​​内容(这可能不是最好/最干净的选择):

    • 使用安装笔记本pip3 install jupyter
    • 使用安装散景pip3 install bokeh
    • jupyter notebook使用(不激活虚拟环境)启动笔记本
  2. 您在虚拟环境下运行所有​​内容:

    • 激活您的虚拟环境
    • 使用安装笔记本python -m pip install jupyter
    • 使用安装散景python -m pip install bokeh
    • 使用启动笔记本jupyter notebook
于 2018-10-10T08:40:11.497 回答
2

我在这里遇到了同样的问题。显然,pip安装存在一些问题。我通过重新安装解决了我的bokeh问题conda

于 2018-10-10T07:33:51.860 回答
1

您可以同时拥有两个版本pip( pip2, pip3)。

pip可以与是否pip2/python2pip3/python3

对我来说,pipPython 3.xPython 2.7Python 3.xpip2相关联:pip3

$ 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版本:

$ python -V
Python 2.7.12

$ python3 -V
Python 3.6.6

在这种情况下,您应该为两个版本的 Python安装散景:

pip3 install bokeh
pip2 install bokeh

测试:

$ 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
>>> 

[注意]:

请参阅以下链接以安装两个版本pip

于 2018-10-11T08:01:42.783 回答