【问题标题】:Fail to import IPython parallel in Jupyter无法在 Jupyter 中并行导入 IPython
【发布时间】:2015-09-24 10:29:15
【问题描述】:

我最近将 IPython 更新到 4.0.0 并安装了 Jupyter 4.0.6。

我想用Ipython并行,在notebook中启动引擎后,我导入了:

from IPython import parallel

它失败了:

~/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/utils/traitlets.py:5: UserWarning: IPython.utils.traitlets has moved to a top-level traitlets package.
  warn("IPython.utils.traitlets has moved to a top-level traitlets package.")
~/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/utils/pickleutil.py:3: UserWarning: IPython.utils.pickleutil has moved to ipykernel.pickleutil
  warn("IPython.utils.pickleutil has moved to ipykernel.pickleutil")
~/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/utils/jsonutil.py:3: UserWarning: IPython.utils.jsonutil has moved to jupyter_client.jsonutil
  warn("IPython.utils.jsonutil has moved to jupyter_client.jsonutil")
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-5652e9e33a4d> in <module>()
----> 1 from IPython import parallel

~/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/parallel/__init__.py in <module>()
     31 
     32 from .client.asyncresult import *
---> 33 from .client.client import Client
     34 from .client.remotefunction import *
     35 from .client.view import *

~/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/parallel/client/client.py in <module>()
     38 from IPython.utils.capture import RichOutput
     39 from IPython.utils.coloransi import TermColors
---> 40 from IPython.utils.jsonutil import rekey, extract_dates, parse_date
     41 from IPython.utils.localinterfaces import localhost, is_local_ip
     42 from IPython.utils.path import get_ipython_dir

ImportError: cannot import name rekey

所以我尝试了:

pip install rekey

但没有找到分布。

请注意,它在笔记本中以相同的方式失败,无论是使用ipython notebookjupyter notebook 打开,还是在控制台中。

还要注意有一个警告:

UserWarning: IPython.utils.jsonutil has moved to jupyter_client.jsonutil

但是rekey在模块jupyter_client.jsonutil中不存在

问题:如何让 IPython 并行工作以在 Jupyter 中工作? 我错过了什么?

【问题讨论】:

    标签: ipython jupyter ipython-parallel


    【解决方案1】:

    我发现了我认为的问题(至少它有效):


    编辑:我得到了这个 OSError,但修复显然没用,没有它也可以工作。不过,我仍然不明白为什么会出现此错误。

    • 然后,我在启动客户端时遇到了另一个错误:

      OSError: Connection file '~/.ipython/profile_default/security/ipcontroller-client.json' not found.
      You have attempted to connect to an IPython Cluster but no Controller could be found.
      Please double-check your configuration and ensure that a cluster is running.
      

    所以我只是将目录~/.ipython/profile_default复制到~/.jupyter/profile_default

    它有效!

    【讨论】:

    • 移动 ~/.ipython/profile_default 到 ~/.jupyter/profile_default 相当于删除配置文件目录。 ~/.jupyter/profile_default 不搜索任何文件。 ipyparallel 的连接文件仍在 ~/.ipython/profile_default/security/
    • @minrk 所以如果我删除~/.jupyter/profile_default,它应该还能工作吗?不然怎么解决OSError
    • 你说得对,它仍在工作。那为什么我会收到这个错误?
    • 错误只是连接文件不存在(控制器可能没有正常启动,或者文件可能已被删除)。它可能与迁移无关,并且再次启动控制器可能是修复它的原因。
    猜你喜欢
    • 2017-02-03
    • 2016-12-27
    • 1970-01-01
    • 1970-01-01
    • 2018-04-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-02
    相关资源
    最近更新 更多