快速旁注:
这个问题基于问题#7947 inipython
的错误跟踪器。该问题似乎与OSX
我的 mac 上的任何一个或一些奇怪的设置有关(可能两者兼而有之)。我无法在新的 Ubuntu 机器上重现它。
我知道潜在的问题可能很复杂。知道它是否可以重现OSX
或者只是我自己已经是一个很大的帮助。
我正在尝试jupyter
为我的 python 版本设置多个内核。具体来说,我有两个conda
环境sci27
,sci34
正如名称已经暗示的那样,前者运行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
环境中运行。