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

智能推荐

oracle 12c 集群安装后的检查_12c查看crs状态-程序员宅基地

文章浏览阅读1.6k次。安装配置gi、安装数据库软件、dbca建库见下:http://blog.csdn.net/kadwf123/article/details/784299611、检查集群节点及状态:[root@rac2 ~]# olsnodes -srac1 Activerac2 Activerac3 Activerac4 Active[root@rac2 ~]_12c查看crs状态

解决jupyter notebook无法找到虚拟环境的问题_jupyter没有pytorch环境-程序员宅基地

文章浏览阅读1.3w次,点赞45次,收藏99次。我个人用的是anaconda3的一个python集成环境,自带jupyter notebook,但在我打开jupyter notebook界面后,却找不到对应的虚拟环境,原来是jupyter notebook只是通用于下载anaconda时自带的环境,其他环境要想使用必须手动下载一些库:1.首先进入到自己创建的虚拟环境(pytorch是虚拟环境的名字)activate pytorch2.在该环境下下载这个库conda install ipykernelconda install nb__jupyter没有pytorch环境

国内安装scoop的保姆教程_scoop-cn-程序员宅基地

文章浏览阅读5.2k次,点赞19次,收藏28次。选择scoop纯属意外,也是无奈,因为电脑用户被锁了管理员权限,所有exe安装程序都无法安装,只可以用绿色软件,最后被我发现scoop,省去了到处下载XXX绿色版的烦恼,当然scoop里需要管理员权限的软件也跟我无缘了(譬如everything)。推荐添加dorado这个bucket镜像,里面很多中文软件,但是部分国外的软件下载地址在github,可能无法下载。以上两个是官方bucket的国内镜像,所有软件建议优先从这里下载。上面可以看到很多bucket以及软件数。如果官网登陆不了可以试一下以下方式。_scoop-cn

Element ui colorpicker在Vue中的使用_vue el-color-picker-程序员宅基地

文章浏览阅读4.5k次,点赞2次,收藏3次。首先要有一个color-picker组件 <el-color-picker v-model="headcolor"></el-color-picker>在data里面data() { return {headcolor: ’ #278add ’ //这里可以选择一个默认的颜色} }然后在你想要改变颜色的地方用v-bind绑定就好了,例如:这里的:sty..._vue el-color-picker

迅为iTOP-4412精英版之烧写内核移植后的镜像_exynos 4412 刷机-程序员宅基地

文章浏览阅读640次。基于芯片日益增长的问题,所以内核开发者们引入了新的方法,就是在内核中只保留函数,而数据则不包含,由用户(应用程序员)自己把数据按照规定的格式编写,并放在约定的地方,为了不占用过多的内存,还要求数据以根精简的方式编写。boot启动时,传参给内核,告诉内核设备树文件和kernel的位置,内核启动时根据地址去找到设备树文件,再利用专用的编译器去反编译dtb文件,将dtb还原成数据结构,以供驱动的函数去调用。firmware是三星的一个固件的设备信息,因为找不到固件,所以内核启动不成功。_exynos 4412 刷机

Linux系统配置jdk_linux配置jdk-程序员宅基地

文章浏览阅读2w次,点赞24次,收藏42次。Linux系统配置jdkLinux学习教程,Linux入门教程(超详细)_linux配置jdk

随便推点

matlab(4):特殊符号的输入_matlab微米怎么输入-程序员宅基地

文章浏览阅读3.3k次,点赞5次,收藏19次。xlabel('\delta');ylabel('AUC');具体符号的对照表参照下图:_matlab微米怎么输入

C语言程序设计-文件(打开与关闭、顺序、二进制读写)-程序员宅基地

文章浏览阅读119次。顺序读写指的是按照文件中数据的顺序进行读取或写入。对于文本文件,可以使用fgets、fputs、fscanf、fprintf等函数进行顺序读写。在C语言中,对文件的操作通常涉及文件的打开、读写以及关闭。文件的打开使用fopen函数,而关闭则使用fclose函数。在C语言中,可以使用fread和fwrite函数进行二进制读写。‍ Biaoge 于2024-03-09 23:51发布 阅读量:7 ️文章类型:【 C语言程序设计 】在C语言中,用于打开文件的函数是____,用于关闭文件的函数是____。

Touchdesigner自学笔记之三_touchdesigner怎么让一个模型跟着鼠标移动-程序员宅基地

文章浏览阅读3.4k次,点赞2次,收藏13次。跟随鼠标移动的粒子以grid(SOP)为partical(SOP)的资源模板,调整后连接【Geo组合+point spirit(MAT)】,在连接【feedback组合】适当调整。影响粒子动态的节点【metaball(SOP)+force(SOP)】添加mouse in(CHOP)鼠标位置到metaball的坐标,实现鼠标影响。..._touchdesigner怎么让一个模型跟着鼠标移动

【附源码】基于java的校园停车场管理系统的设计与实现61m0e9计算机毕设SSM_基于java技术的停车场管理系统实现与设计-程序员宅基地

文章浏览阅读178次。项目运行环境配置:Jdk1.8 + Tomcat7.0 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)。项目技术:Springboot + mybatis + Maven +mysql5.7或8.0+html+css+js等等组成,B/S模式 + Maven管理等等。环境需要1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。_基于java技术的停车场管理系统实现与设计

Android系统播放器MediaPlayer源码分析_android多媒体播放源码分析 时序图-程序员宅基地

文章浏览阅读3.5k次。前言对于MediaPlayer播放器的源码分析内容相对来说比较多,会从Java-&amp;amp;gt;Jni-&amp;amp;gt;C/C++慢慢分析,后面会慢慢更新。另外,博客只作为自己学习记录的一种方式,对于其他的不过多的评论。MediaPlayerDemopublic class MainActivity extends AppCompatActivity implements SurfaceHolder.Cal..._android多媒体播放源码分析 时序图

java 数据结构与算法 ——快速排序法-程序员宅基地

文章浏览阅读2.4k次,点赞41次,收藏13次。java 数据结构与算法 ——快速排序法_快速排序法