Fail to import IPython parallel in Jupyter

故事扮演 提交于 2019-12-24 17:19:21

问题


I recently made an update of IPython to 4.0.0 and installed Jupyter 4.0.6.

I wanted to use Ipython parallel, and after starting the engines in the notebook, I imported:

from IPython import parallel

And it fails:

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

So I tried:

pip install rekey

But no distribution were found.

Note that it fails the same way in the notebook, be it open with ipython notebook or jupyter notebook, and in the console.

Also note that there is a warning:

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

But rekey does not exist in the module jupyter_client.jsonutil

Question: How can I have IPython parallel to work within Jupyter ? What am I missing ?


回答1:


I found the problem I think (at least it works):

  • First, I had to import ipyparallel instead of IPython.parallel See here: http://jupyter.readthedocs.org/en/latest/migrating.html#imports

EDIT: I get this OSError, but the fix was apparently useless, and it works without. I still don't get why I had this error, though.

  • Then, I had another error, when starting the client:

    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.
    

So I just copy the directory ~/.ipython/profile_default to ~/.jupyter/profile_default

And it works!



来源:https://stackoverflow.com/questions/32759056/fail-to-import-ipython-parallel-in-jupyter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!