Jupyter Notebook中未显示Conda环境 [英] Conda environments not showing up in Jupyter Notebook

查看:1437
本文介绍了Jupyter Notebook中未显示Conda环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了Anaconda(使用Python 2.7),并在名为tensorflow的环境中安装了Tensorflow.我可以在该环境中成功导入Tensorflow.

I installed Anaconda (with Python 2.7), and installed Tensorflow in an environment called tensorflow. I can import Tensorflow successfully in that environment.

问题在于Jupyter Notebook无法识别我刚刚创建的新环境.无论我是从GUI导航器还是在tensorflow env内的命令行 中启动Jupyter Notebook,菜单中只有一个名为Python [Root]的内核,并且Tensorflow无法导入.当然,我多次单击该选项,保存了文件,然后重新打开,但是这些都无济于事.

The problem is that Jupyter Notebook does not recognize the new environment I just created. No matter I start Jupyter Notebook from the GUI Navigator or from the command line within the tensorflow env, there is only one kernel in the menu called Python [Root], and Tensorflow cannot be imported. Of course, I clicked on that option multiple times, saved file, re-opened, but these did not help.

奇怪的是,当我打开Jupyter主页上的Conda选项卡时,可以看到两种环境.但是,当我打开Files选项卡并尝试new笔记本时,我仍然只剩下一个内核.

Strangely, I can see the two environments when I open the Conda tab on the front page of Jupyter. But when I open the Files tab, and try to new a notebook, I still end up with only one kernel.

我看了这个问题: 使用Jupyter Notebook链接Conda环境 但是我的计算机上没有~/Library/Jupyter/kernels这样的目录!该Jupyter目录只有一个名为runtime的子目录.

I looked at this question: Link Conda environment with Jupyter Notebook But there isn't such a directory as ~/Library/Jupyter/kernels on my computer! This Jupyter directory only has one sub-directory called runtime.

我真的很困惑.是否应该将Conda环境自动变成内核? (我遵循了 https://ipython.readthedocs.io/en/stable/install/kernel_install.html手动设置内核,但被告知未找到ipykernel.

I am really confused. Are Conda environments supposed to become kernels automatically? (I followed https://ipython.readthedocs.io/en/stable/install/kernel_install.html to manually set up the kernels, but was told that ipykernel was not found.)

推荐答案

我认为其他答案不再有效,因为conda停止自动将环境设置为jupyter内核.您需要通过以下方式为每个环境手动添加内核:

I don't think the other answers are working any more, as conda stopped automatically setting environments up as jupyter kernels. You need to manually add kernels for each environment in the following way:

source activate myenv
python -m ipykernel install --user --name myenv --display-name "Python (myenv)"

如此处所述: http://ipython.readthedocs.io/en/stable/install/kernel_install.html#kernels-for-different-environments 另请参见此问题.

As documented here:http://ipython.readthedocs.io/en/stable/install/kernel_install.html#kernels-for-different-environments Also see this issue.

附录: 您应该能够将nb_conda_kernels软件包与conda install nb_conda_kernels一起安装,以自动添加所有环境,请参见 https://github.com/Anaconda-Platform/nb_conda_kernels

Addendum: You should be able to install the nb_conda_kernels package with conda install nb_conda_kernels to add all environments automatically, see https://github.com/Anaconda-Platform/nb_conda_kernels

这篇关于Jupyter Notebook中未显示Conda环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆