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

时间:2015-05-02 11:09:51

标签: python macos ipython anaconda jupyter

快速注释

此问题基于ipython的错误跟踪器中的问题#7947。问题似乎是与OSX相关的问题,或者我的mac上的一些奇怪的设置(可能两者)。我无法在新的Ubuntu盒子上重现它。

我知道潜在的问题可能很复杂。知道它是否可以在OSX上重现,或者它是否只是我的帮助。

我正在尝试为我的python版本设置多个jupyter内核。具体来说,我有两个conda环境sci27sci34,因为名称已经建议前者运行python2.7解释器,后者运行python3.4解释器。

所以我现在所做的是:

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

现在我在/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}"
 ]
}

我在ipython环境中启动sci34

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

消息/Users/ch/miniconda/envs/sci34/bin/python: No module named IPython让我感到惊讶。为什么jupyter会尝试拨打sci34的翻译而不是sci27的翻译?

另外,为什么module not found消息?显然/Users/ch/miniconda/envs/sci34/bin/python -m IPython工作正常,因为笔记本服务器从sci34环境运行。

1 个答案:

答案 0 :(得分:0)

更新到IPython 3.2.0将解决此问题。有关详细信息,请参阅提取请求PR-8527