Jupyter Notebook中未显示Conda环境_jupyter notebook没有conda-程序员宅基地

技术标签: jupyter  jupyter-notebook  anaconda  conda  

本文翻译自:Conda environments not showing up in Jupyter Notebook

I installed Anaconda (with Python 2.7), and installed Tensorflow in an environment called tensorflow . 我安装了Anaconda(使用Python 2.7),并在名为tensorflow的环境中安装了tensorflow I can import Tensorflow successfully in that environment. 我可以在该环境中成功导入Tensorflow。

The problem is that Jupyter Notebook does not recognize the new environment I just created. 问题在于Jupyter Notebook无法识别我刚刚创建的新环境。 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. 无论我从GUI导航还是从内部的命令行启动Jupyter笔记本tensorflow ENV,只有一个名为菜单内核Python [Root] ,并且Tensorflow无法导入。 Of course, I clicked on that option multiple times, saved file, re-opened, but these did not help. 当然,我多次单击该选项,保存了文件,然后重新打开,但是这些无济于事。

Strangely, I can see the two environments when I open the Conda tab on the front page of Jupyter. 奇怪的是,当我打开Jupyter主页上的Conda选项卡时,可以看到两种环境。 But when I open the Files tab, and try to new a notebook, I still end up with only one kernel. 但是,当我打开Files选项卡,并尝试new笔记本,我还是结束了只有一个内核。

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! 我看着这个问题: 用Jupyter Notebook链接Conda环境但是我的计算机上没有~/Library/Jupyter/kernels这样的目录! This Jupyter directory only has one sub-directory called runtime . 这个Jupyter目录只有一个子目录,称为runtime

I am really confused. 我真的很困惑。 Are Conda environments supposed to become kernels automatically? Conda环境是否应该自动成为内核? (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.) (我按照https://ipython.readthedocs.io/en/stable/install/kernel_install.html手动设置了内核,但被告知未找到ipykernel 。)


#1楼

参考:https://stackoom.com/question/2gAsZ/Jupyter-Notebook中未显示Conda环境


#2楼

The annoying thing is that in your tensorflow environment, you can run jupyter notebook without installing jupyter in that environment . 令人讨厌的是,在您的张量tensorflow环境中,您可以运行jupyter notebook 而无需在该环境中安装jupyter Just run 赶紧跑

(tensorflow) $ conda install jupyter

and the tensorflow environment should now be visible in Jupyter Notebooks started in any of your conda environments as something like Python [conda env:tensorflow] . tensorflow环境现在应该是可见的Jupyter笔记本电脑在你的任何启动conda环境,因为类似Python [conda env:tensorflow]


#3楼

If your environments are not showing up, you probably do not have nb_conda_kernels installed in the environment where Jupyter is installed. 如果您的环境未显示,则可能是在安装nb_conda_kernels的环境中未安装nb_conda_kernels。 Anaconda's documentation states that Anaconda的文档指出

nb_conda_kernels should be installed in the environment from which you run Jupyter Notebook or JupyterLab. nb_conda_kernels应该安装在运行Jupyter Notebook或JupyterLab的环境中。 This might be your base conda environment, but it need not be. 这可能是您的基本conda环境,但不一定如此。 For instance, if the environment notebook_env contains the notebook package, then you would run 例如,如果环境notebook_env包含notebook软件包,则可以运行

 conda install -n notebook_env nb_conda_kernels 

Any other environments you wish to access in your notebooks must have an appropriate kernel package installed. 您希望在笔记本中访问的任何其他环境都必须安装适当的内核软件包。 For instance, to access a Python environment, it must have the ipykernel package; 例如,要访问Python环境,它必须具有ipykernel软件包。 eg 例如

 conda install -n python_env ipykernel 

To utilize an R environment, it must have the r-irkernel package; 要使用R环境,它必须具有r-irkernel软件包。 eg 例如

 conda install -n r_env r-irkernel 

For other languages, their corresponding kernels must be installed. 对于其他语言,必须安装其相应的内核

Note that at the time originally posting this, there was a possible cause from nb_conda not yet supporting Python 3.6 environments . 请注意,在最初发布此内容时,可能是由于nb_conda不支持Python 3.6环境引起的

If other solutions fail to get Jupyter to recognize other conda environments, you can always install and run jupyter from within a specific environment. 如果其他解决方案无法使Jupyter识别其他conda环境,则始终可以在特定环境中安装并运行jupyter You may not be able to see or switch to other environments from within Jupyter though. 但是,您可能无法从Jupyter内部查看或切换到其他环境。

$ conda create -n py36_test -y python=3.6 jupyter
$ source activate py36_test
(py36_test) $ which jupyter
/home/schowell/anaconda3/envs/py36_test/bin/jupyter
(py36_test) $ jupyter notebook

Notice that I am running Python 3.6.1 in this notebook: 请注意,我正在此笔记本中运行Python 3.6.1: 在此处输入图片说明

Note that if you do this with many environments, the added storage space from installing Jupyter into every environment may be undesirable (depending on your system). 请注意,如果您在许多环境中执行此操作,则可能不希望将Jupyter安装到每个环境中而增加存储空间(取决于您的系统)。


#4楼

Just run conda install ipykernel in your new environment, only then you will get a kernel with this env. 只要在您的新环境中运行conda install ipykernel ,就可以使用此env获得内核。 This works even if you have different versions installed in each envs and it doesn't install jupyter notebook again. 即使您在每个环境中安装了不同的版本,也不会再次安装jupyter Notebook,此方法仍然有效。 You can start youe notebook from any env you will be able to see newly added kernels. 您可以从任何环境中启动笔记本,您将能够看到新添加的内核。


#5楼

I ran into this same problem where my new conda environment, myenv , couldn't be selected as a kernel or a new notebook. 我遇到了同样的问题,我的新conda环境myenv无法选择为内核或新笔记本。 And running jupter notebook from within the env gave the same result. 从环境中运行jupter notebook可以得到相同的结果。

My solution, and what I learned about how Jupyter notebooks recognizes conda-envs and kernels: 我的解决方案以及有关Jupyter笔记本如何识别conda-envs和内核的知识:

Installing jupyter and ipython to myenv with conda: 使用conda将jupyter和ipython安装到myenv

conda install -n myenv ipython jupyter

After that, running jupter notebook outside any env listed myenv as a kernel along with my previous environments. 之后,在任何环境之外运行jupter notebookmyenv与以前的环境一起列为内核。

Python [conda env:old]
Python [conda env:myenv]

Running the notebook once I activated the environment: 激活环境后运行笔记本:

source activate myenv
jupyter notebook

hides all my other environment-kernels and only shows my language kernels: 隐藏我所有其他环境内核,只显示我的语言内核:

python 2
python 3
R

#6楼

I don't think the other answers are working any more, as conda stopped automatically setting environments up as jupyter kernels. 我认为其他答案不再有效,因为conda停止自动将环境设置为jupyter内核。 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)"

As documented here: http://ipython.readthedocs.io/en/stable/install/kernel_install.html#kernels-for-different-environments Also see this issue . 如此处所述: http : //ipython.readthedocs.io/zh-CN/stable/install/kernel_install.html#kernels-for-different-environments也请参阅此问题

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 附录:您应该能够通过nb_conda_kernels conda install nb_conda_kernels安装nb_conda_kernels软件包,以自动添加所有环境,请参见https://github.com/Anaconda-Platform/nb_conda_kernels

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/p15097962069/article/details/107405745

智能推荐

攻防世界_难度8_happy_puzzle_攻防世界困难模式攻略图文-程序员宅基地

文章浏览阅读645次。这个肯定是末尾的IDAT了,因为IDAT必须要满了才会开始一下个IDAT,这个明显就是末尾的IDAT了。,对应下面的create_head()代码。,对应下面的create_tail()代码。不要考虑爆破,我已经试了一下,太多情况了。题目来源:UNCTF。_攻防世界困难模式攻略图文

达梦数据库的导出(备份)、导入_达梦数据库导入导出-程序员宅基地

文章浏览阅读2.9k次,点赞3次,收藏10次。偶尔会用到,记录、分享。1. 数据库导出1.1 切换到dmdba用户su - dmdba1.2 进入达梦数据库安装路径的bin目录,执行导库操作  导出语句:./dexp cwy_init/[email protected]:5236 file=cwy_init.dmp log=cwy_init_exp.log 注释:   cwy_init/init_123..._达梦数据库导入导出

js引入kindeditor富文本编辑器的使用_kindeditor.js-程序员宅基地

文章浏览阅读1.9k次。1. 在官网上下载KindEditor文件,可以删掉不需要要到的jsp,asp,asp.net和php文件夹。接着把文件夹放到项目文件目录下。2. 修改html文件,在页面引入js文件:<script type="text/javascript" src="./kindeditor/kindeditor-all.js"></script><script type="text/javascript" src="./kindeditor/lang/zh-CN.js"_kindeditor.js

STM32学习过程记录11——基于STM32G431CBU6硬件SPI+DMA的高效WS2812B控制方法-程序员宅基地

文章浏览阅读2.3k次,点赞6次,收藏14次。SPI的详情简介不必赘述。假设我们通过SPI发送0xAA,我们的数据线就会变为10101010,通过修改不同的内容,即可修改SPI中0和1的持续时间。比如0xF0即为前半周期为高电平,后半周期为低电平的状态。在SPI的通信模式中,CPHA配置会影响该实验,下图展示了不同采样位置的SPI时序图[1]。CPOL = 0,CPHA = 1:CLK空闲状态 = 低电平,数据在下降沿采样,并在上升沿移出CPOL = 0,CPHA = 0:CLK空闲状态 = 低电平,数据在上升沿采样,并在下降沿移出。_stm32g431cbu6

计算机网络-数据链路层_接收方收到链路层数据后,使用crc检验后,余数为0,说明链路层的传输时可靠传输-程序员宅基地

文章浏览阅读1.2k次,点赞2次,收藏8次。数据链路层习题自测问题1.数据链路(即逻辑链路)与链路(即物理链路)有何区别?“电路接通了”与”数据链路接通了”的区别何在?2.数据链路层中的链路控制包括哪些功能?试讨论数据链路层做成可靠的链路层有哪些优点和缺点。3.网络适配器的作用是什么?网络适配器工作在哪一层?4.数据链路层的三个基本问题(帧定界、透明传输和差错检测)为什么都必须加以解决?5.如果在数据链路层不进行帧定界,会发生什么问题?6.PPP协议的主要特点是什么?为什么PPP不使用帧的编号?PPP适用于什么情况?为什么PPP协议不_接收方收到链路层数据后,使用crc检验后,余数为0,说明链路层的传输时可靠传输

软件测试工程师移民加拿大_无证移民,未受过软件工程师的教育(第1部分)-程序员宅基地

文章浏览阅读587次。软件测试工程师移民加拿大 无证移民,未受过软件工程师的教育(第1部分) (Undocumented Immigrant With No Education to Software Engineer(Part 1))Before I start, I want you to please bear with me on the way I write, I have very little gen...

随便推点

Thinkpad X250 secure boot failed 启动失败问题解决_安装完系统提示secureboot failure-程序员宅基地

文章浏览阅读304次。Thinkpad X250笔记本电脑,装的是FreeBSD,进入BIOS修改虚拟化配置(其后可能是误设置了安全开机),保存退出后系统无法启动,显示:secure boot failed ,把自己惊出一身冷汗,因为这台笔记本刚好还没开始做备份.....根据错误提示,到bios里面去找相关配置,在Security里面找到了Secure Boot选项,发现果然被设置为Enabled,将其修改为Disabled ,再开机,终于正常启动了。_安装完系统提示secureboot failure

C++如何做字符串分割(5种方法)_c++ 字符串分割-程序员宅基地

文章浏览阅读10w+次,点赞93次,收藏352次。1、用strtok函数进行字符串分割原型: char *strtok(char *str, const char *delim);功能:分解字符串为一组字符串。参数说明:str为要分解的字符串,delim为分隔符字符串。返回值:从str开头开始的一个个被分割的串。当没有被分割的串时则返回NULL。其它:strtok函数线程不安全,可以使用strtok_r替代。示例://借助strtok实现split#include <string.h>#include <stdio.h&_c++ 字符串分割

2013第四届蓝桥杯 C/C++本科A组 真题答案解析_2013年第四届c a组蓝桥杯省赛真题解答-程序员宅基地

文章浏览阅读2.3k次。1 .高斯日记 大数学家高斯有个好习惯:无论如何都要记日记。他的日记有个与众不同的地方,他从不注明年月日,而是用一个整数代替,比如:4210后来人们知道,那个整数就是日期,它表示那一天是高斯出生后的第几天。这或许也是个好习惯,它时时刻刻提醒着主人:日子又过去一天,还有多少时光可以用于浪费呢?高斯出生于:1777年4月30日。在高斯发现的一个重要定理的日记_2013年第四届c a组蓝桥杯省赛真题解答

基于供需算法优化的核极限学习机(KELM)分类算法-程序员宅基地

文章浏览阅读851次,点赞17次,收藏22次。摘要:本文利用供需算法对核极限学习机(KELM)进行优化,并用于分类。

metasploitable2渗透测试_metasploitable2怎么进入-程序员宅基地

文章浏览阅读1.1k次。一、系统弱密码登录1、在kali上执行命令行telnet 192.168.26.1292、Login和password都输入msfadmin3、登录成功,进入系统4、测试如下:二、MySQL弱密码登录:1、在kali上执行mysql –h 192.168.26.129 –u root2、登录成功,进入MySQL系统3、测试效果:三、PostgreSQL弱密码登录1、在Kali上执行psql -h 192.168.26.129 –U post..._metasploitable2怎么进入

Python学习之路:从入门到精通的指南_python人工智能开发从入门到精通pdf-程序员宅基地

文章浏览阅读257次。本文将为初学者提供Python学习的详细指南,从Python的历史、基础语法和数据类型到面向对象编程、模块和库的使用。通过本文,您将能够掌握Python编程的核心概念,为今后的编程学习和实践打下坚实基础。_python人工智能开发从入门到精通pdf

推荐文章

热门文章

相关标签