要查找该文件夹,您可以使用 which PYTHON 例如 which python3.6 (如果您使用的是pyenv,则为 pyenv which python3.6 !) . 然后
ls -la `which python3.6`
将显示可执行文件的位置 .
List again:
$ jupyter kernelspec list
Available kernels:
python3 /usr/local/lib/python3.6/site-packages/ipykernel/resources
python2 /Users/stefano/Library/Jupyter/kernels/python2
$ jupyter kernelspec help
Manage Jupyter kernel specifications.
Subcommands
-----------
Subcommands are launched as `jupyter kernelspec cmd [args]`. For information on
using subcommand 'cmd', do: `jupyter kernelspec cmd -h`.
list
List installed kernel specifications.
install
Install a kernel specification directory.
uninstall
Alias for remove
remove
Remove one or more Jupyter kernelspecs by name.
install-self
[DEPRECATED] Install the IPython kernel spec directory for this Python.
To see all available configurables, use `--help-all`
(py3k)Monas-MacBook-Pro:cs799 mona$ ipython kernelspec install-self
[TerminalIPythonApp] WARNING | Subcommand `ipython kernelspec` is deprecated and will be removed in future versions.
[TerminalIPythonApp] WARNING | You likely want to use `jupyter kernelspec` in the future
[InstallNativeKernelSpec] WARNING | `jupyter kernelspec install-self` is DEPRECATED as of 4.0. You probably want `ipython kernel install` to install the IPython kernelspec.
[InstallNativeKernelSpec] Installed kernelspec python3 in /usr/local/share/jupyter/kernels/python3
(py3k)Monas-MacBook-Pro:cs799 mona$ ipython kernel install
Installed kernelspec python3 in /usr/local/share/jupyter/kernels/python3
18 回答
在Ubuntu 14.04上,我不得不使用以前的答案组合 .
首先,安装
pip3
apt-get install python-pip3
然后用
pip3
安装jupyterpip3 install jupyter
然后使用
ipython3
安装内核ipython3 kernel install
这是我找到的Windows /非命令行方法,它对我有用:找到存储内核文件的文件夹(在我的机器上 - C:\ ProgramData \ jupyter \ kernels - 注意ProgramData是一个隐藏文件夹),创建一个复制现有内核的文件夹,更改名称并编辑其中的json文件以指向新内核的目录 . 在这个json中你还可以编辑ipython中显示的内核名称(例如,如果你因某些原因需要进一步区分,你可以指定2.7.9而不是python 2) .
我很确定你所要做的就是跑步
pip3安装jupyter
对于当前的Python启动器
如果安装了Py3但默认为py2
如果安装了Py2但默认为py3
我有Python 2.7,并希望能够在Jupyter内部切换到Python 3 .
这些步骤适用于Windows Anaconda命令提示符:
现在,在使用Python2.7的常用命令打开ipython笔记本之后,在创建新笔记本时也可以使用Python3.3 .
for recent versions of jupyter/ipython :使用
jupyter kernelspec
列出当前内核
在我的情况下,python3内核设置被破坏,因为py3.5链接不再存在,取而代之的是py3.6
添加/删除内核
Remove:
Add a new one:
要查找该文件夹,您可以使用
which PYTHON
例如which python3.6
(如果您使用的是pyenv,则为pyenv which python3.6
!) . 然后将显示可执行文件的位置 .
List again:
Doc:https://jupyter-client.readthedocs.io/en/latest/kernels.html#kernelspecs
详情
可用的内核列在Jupyter DATA DIRECTORY的
kernels
文件夹下(有关详细信息,请参阅http://jupyter.readthedocs.io/en/latest/projects/jupyter-directories.html) .例如在macosx上
/Users/YOURUSERNAME/Library/Jupyter/kernels/
内核简单地由
kernel.json
文件描述,例如 . 为/Users/me/Library/Jupyter/kernels/python3/kernel.json
而不是手动操作,您可以使用
kernelspec
命令(如上所述) . 它以前通过ipython现在通过jupyter(http://ipython.readthedocs.io/en/stable/install/kernel_install.html#kernels-for-different-environments - https://jupyter-client.readthedocs.io/en/latest/kernels.html#kernelspecs)获得 .其他语言的内核
顺便说一句,与这个问题并没有严格的关系,但是还有很多其他内核可供使用... https://github.com/jupyter/jupyter/wiki/Jupyter-kernels
以下命令适用于我,在macOS Sierra(10.12.3)
用jupyter kernelspec列表检查它可用的内核:python3 / Users / admin / Library / Jupyter / kernels / python3 python2 / anaconda2 / share / jupyter / kernels / python2
确保安装了
ipykernel
并使用ipython kernel install
将kernelspec放在python2的正确位置 . 然后是ipython3 kernel install
for Python3 . 现在,您应该能够在2个内核之间进行选择,无论您使用jupyter notebook
,ipython notebook
还是ipython3 notebook
(后两个都已弃用) .请注意,如果要为特定的Python可执行文件安装,可以使用以下技巧:
这适用于使用环境(venv,conda,...)和
<options>
让你命名你的内核(见--help
) . 所以你可以做到现在,您在下拉菜单中获得了一个名为
py36-test
的内核,以及其他内核 .请参阅Using both Python 2.x and Python 3.x in IPython Notebook,其中包含更多最新信息 .
用Python2获得ipython笔记本(在Windows7上)
用
pip install -U jupyter
升级到Jupyter安装Python3
再次使用
pip3 install jupyter
安装Jupyter使用
ipython3 kernelspec install-self
安装Python3内核我终于有了2个工作内核 .
打开终端(或窗口的cmd),然后运行以下命令:(在窗口中,在第二行中删除“source” . )
我尝试了一些方法,但它不起作用,然后我发现了这种方式 . 它与我合作 . 希望它可以帮助 .
在ElementaryOS Freya(基于Ubuntu 14.04)中,没有其他答案立即为我工作;我得到了
在_329920的答案下,quickbug描述的错误 . 我不得不先做:
sudo apt-get install pip3
,然后sudo pip3 install ipython[all]
此时,您可以运行Matt建议的命令;即:
ipython kernelspec install-self
和ipython3 kernelspec install-self
现在,当我启动
ipython notebook
然后打开笔记本时,我可以从内核菜单中选择Python 3内核 .这在Ubuntu 16.04上对我有用:
参考文档:
Kernels for Python 2 and 3 . 安装IPython内核 - IPython文档 .
我在macOS El Capitan上成功安装了python3内核(ipython版本:4.1.0)使用以下命令 .
您可以使用
jupyter kernelspec list
查看所有已安装的内核 .更多信息可用here
我设法安装除Python2之外的Python3内核 . 这是我做的方式:
在Jupyter打开一个新的笔记本
复制并运行这两个单元格:Enable-Python-3-kernel
最新的工作链接可以在here找到 .
实际代码是:
如果你使用anaconda发行版,这对我有用(在macintosh上):
只是最后一个命令的注释:
通过以上步骤在OSX Yosemite中测试并输入
jupter notebook
并在浏览器中创建新笔记本,您将看到以下屏幕截图:当您使用conda管理您的python环境时,请按照以下两个步骤操作:
activate py3
(在Windows上或Linux上的source activate py3
)conda install notebook ipykernel
或只是使用conda install jupyter
该解决方案在官方文档中有详细记载:https://ipython.readthedocs.org/en/latest/install/kernel_install.html
我尝试了第一种方法 . 由于我已经安装了
ipykernel
,只需运行python3 -m ipykernel install --user
即可解决问题 .