找到你要的答案

Q:jupyter kernels in OSX: No module named IPython

Q:jupyter仁在OSX:没有模块命名为IPython

Quick side note:

This question is based on issue #7947 in ipython's bug tracker. The problem seems to be an issue related to either OSX, or some weird settings on my mac (maybe both). I cannot reproduce it on a fresh Ubuntu box.

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.


I am trying to set up multiple jupyter kernels for my python versions. 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.

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/

{
 "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:

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:

[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. Why would jupyter try to call sci34's interpreter instead of sci27's interpreter?

Also, why the module not found message? Obviously /Users/ch/miniconda/envs/sci34/bin/python -m IPython works perfectly fine, as the notebook server runs from the sci34 environment.

快速侧注:

这个问题是基于问题# 7947 IPython的bug跟踪系统。这个问题似乎是要么OSX相关的一个问题,或者我的Mac上一些奇怪的设置(也许两者都有)。我无法复制在新的Ubuntu盒。

我知道潜在的问题可能是复杂的。知道它是可再生的OSX或如果它只是我已经是一个很大的帮助。


我试图建立我的Python版本多jupyter内核。特别是我有两康大环境sci27和sci34,正如名字已经认为前运行python2.7解释器,后者python3.4解释器。

所以我现在做的是:

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

现在我有我的内核定义在/ usr /局部/分享/ jupyter /核/ python2 /

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

我开始在我的sci34 IPython环境:

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

现在事情越来越奇怪:如果我选择新安装的内核的内核崩溃与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

消息/用户/总/ miniconda / ENVS / sci34 /斌/ Python模块:没有叫IPython很让我吃惊。为什么jupyter试图代替sci27的翻译sci34的翻译吗?

还有,为什么模块没有找到消息?显然/用户/总/ miniconda / ENVS / sci34 /斌/ Python - m IPython工作的非常好,因为从sci34笔记本服务器运行环境。

answer1: 回答1:

Updating to IPython 3.2.0 will fix this issue. For details see pull request PR-8527.

IPython 3.2.0更新将解决这个问题。详情见拉请求pr-8527。

python  osx  ipython  anaconda  jupyter