简体   繁体   English

OSX中的jupyter内核:没有名为IPython的模块

[英]jupyter kernels in OSX: No module named IPython

Quick side note : 快速旁注

This question is based on issue #7947 in ipython 's bug tracker. 该问题基于ipython的错误跟踪器中的问题#7947 The problem seems to be an issue related to either OSX , or some weird settings on my mac (maybe both). 问题似乎是与OSX或我的Mac上的某些怪异设置(也许两者都有)有关的问题。 I cannot reproduce it on a fresh Ubuntu box. 我无法在新的Ubuntu盒上复制它。

I am aware that the underlying problem could be complex. 我知道潜在的问题可能很复杂。 Knowing if it is reproducible on OSX or if it's just me would already be a great help. 知道它是否可以在OSX上重现,或者只是我自己,这将是一个很大的帮助。


I am trying to set up multiple jupyter kernels for my python versions. 我正在尝试为我的python版本设置多个jupyter内核。 Specifically I have two conda environments sci27 and sci34 , as the names already suggest the former runs a python2.7 interpreter, the latter a python3.4 interpreter. 具体来说,我有两个conda环境sci27sci34 ,作为地名已经认为前一个运行python2.7解释,后者python3.4解释。

So what I do now is: 所以我现在要做的是:

source activate sci27
conda install ipython-notebook
ipython kernelspec install-self

Now I have my kernel definition in /usr/local/share/jupyter/kernels/python2/ 现在我在/usr/local/share/jupyter/kernels/python2/有我的内核定义

{
 "display_name": "Python 2",
 "language": "python",
 "argv": [
  "/Users/ch/miniconda/envs/sci27/bin/python",
  "-m",
  "IPython.kernel",
  "-f",
  "{connection_file}"
 ]
}

I start ipython in my sci34 environment: 我在sci34环境中启动ipython

source activate sci34
conda install ipython-notebook
ipython notebook --debug

And now things are getting weird: If I select the freshly installed kernel Python 2 , the kernel crashes with following output: 现在事情变得怪异了:如果我选择新安装的内核Python 2 ,则内核崩溃并显示以下输出:

[D 12:47:53.029 NotebookApp] Opening websocket /api/kernels/4ae0a266-9396-44f7-a529-912056dc6eed/channels
[D 12:47:53.029 NotebookApp] Connecting to: tcp://127.0.0.1:52954
[D 12:47:53.030 NotebookApp] Connecting to: tcp://127.0.0.1:52955
[D 12:47:53.031 NotebookApp] Connecting to: tcp://127.0.0.1:52956
[I 12:47:54.949 NotebookApp] KernelRestarter: restarting kernel (4/5)
WARNING:root:kernel 4ae0a266-9396-44f7-a529-912056dc6eed restarted
[D 12:47:54.954 NotebookApp] Connecting to: tcp://127.0.0.1:52957
/Users/ch/miniconda/envs/sci34/bin/python: No module named IPython
[W 12:47:57.957 NotebookApp] KernelRestarter: restart failed
[W 12:47:57.957 NotebookApp] Kernel 4ae0a266-9396-44f7-a529-912056dc6eed died, removing from map.
ERROR:root:kernel 4ae0a266-9396-44f7-a529-912056dc6eed restarted failed!
[W 12:47:57.975 NotebookApp] Kernel deleted before session
[W 12:47:57.975 NotebookApp] 410 DELETE /api/sessions/70f4d715-807c-4bbc-8a0a-b503aa966606 (::1) 1.40ms referer=http://localhost:8888/notebooks/Untitled2.ipynb?kernel_name=python2

The message /Users/ch/miniconda/envs/sci34/bin/python: No module named IPython is rather surprising to me. 消息/Users/ch/miniconda/envs/sci34/bin/python: No module named IPython令我感到惊讶。 Why would jupyter try to call sci34 's interpreter instead of sci27 's interpreter? 为什么jupyter尝试调用sci34的解释器而不是sci27的解释器?

Also, why the module not found message? 另外,为什么module not found消息? Obviously /Users/ch/miniconda/envs/sci34/bin/python -m IPython works perfectly fine, as the notebook server runs from the sci34 environment. 显然, /Users/ch/miniconda/envs/sci34/bin/python -m IPython可以很好地工作,因为笔记本服务器在sci34环境中运行。

Updating to IPython 3.2.0 will fix this issue. 更新到IPython 3.2.0将解决此问题。 For details see pull request PR-8527 . 有关详细信息,请参阅拉取请求PR-8527

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM