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

智能推荐

c# 调用c++ lib静态库_c#调用lib-程序员宅基地

文章浏览阅读2w次,点赞7次,收藏51次。四个步骤1.创建C++ Win32项目动态库dll 2.在Win32项目动态库中添加 外部依赖项 lib头文件和lib库3.导出C接口4.c#调用c++动态库开始你的表演...①创建一个空白的解决方案,在解决方案中添加 Visual C++ , Win32 项目空白解决方案的创建:添加Visual C++ , Win32 项目这......_c#调用lib

deepin/ubuntu安装苹方字体-程序员宅基地

文章浏览阅读4.6k次。苹方字体是苹果系统上的黑体,挺好看的。注重颜值的网站都会使用,例如知乎:font-family: -apple-system, BlinkMacSystemFont, Helvetica Neue, PingFang SC, Microsoft YaHei, Source Han Sans SC, Noto Sans CJK SC, W..._ubuntu pingfang

html表单常见操作汇总_html表单的处理程序有那些-程序员宅基地

文章浏览阅读159次。表单表单概述表单标签表单域按钮控件demo表单标签表单标签基本语法结构<form action="处理数据程序的url地址“ method=”get|post“ name="表单名称”></form><!--action,当提交表单时,向何处发送表单中的数据,地址可以是相对地址也可以是绝对地址--><!--method将表单中的数据传送给服务器处理,get方式直接显示在url地址中,数据可以被缓存,且长度有限制;而post方式数据隐藏传输,_html表单的处理程序有那些

PHP设置谷歌验证器(Google Authenticator)实现操作二步验证_php otp 验证器-程序员宅基地

文章浏览阅读1.2k次。使用说明:开启Google的登陆二步验证(即Google Authenticator服务)后用户登陆时需要输入额外由手机客户端生成的一次性密码。实现Google Authenticator功能需要服务器端和客户端的支持。服务器端负责密钥的生成、验证一次性密码是否正确。客户端记录密钥后生成一次性密码。下载谷歌验证类库文件放到项目合适位置(我这边放在项目Vender下面)https://github.com/PHPGangsta/GoogleAuthenticatorPHP代码示例://引入谷_php otp 验证器

【Python】matplotlib.plot画图横坐标混乱及间隔处理_matplotlib更改横轴间距-程序员宅基地

文章浏览阅读4.3k次,点赞5次,收藏11次。matplotlib.plot画图横坐标混乱及间隔处理_matplotlib更改横轴间距

docker — 容器存储_docker 保存容器-程序员宅基地

文章浏览阅读2.2k次。①Storage driver 处理各镜像层及容器层的处理细节,实现了多层数据的堆叠,为用户 提供了多层数据合并后的统一视图②所有 Storage driver 都使用可堆叠图像层和写时复制(CoW)策略③docker info 命令可查看当系统上的 storage driver主要用于测试目的,不建议用于生成环境。_docker 保存容器

随便推点

网络拓扑结构_网络拓扑csdn-程序员宅基地

文章浏览阅读834次,点赞27次,收藏13次。网络拓扑结构是指计算机网络中各组件(如计算机、服务器、打印机、路由器、交换机等设备)及其连接线路在物理布局或逻辑构型上的排列形式。这种布局不仅描述了设备间的实际物理连接方式,也决定了数据在网络中流动的路径和方式。不同的网络拓扑结构影响着网络的性能、可靠性、可扩展性及管理维护的难易程度。_网络拓扑csdn

JS重写Date函数,兼容IOS系统_date.prototype 将所有 ios-程序员宅基地

文章浏览阅读1.8k次,点赞5次,收藏8次。IOS系统Date的坑要创建一个指定时间的new Date对象时,通常的做法是:new Date("2020-09-21 11:11:00")这行代码在 PC 端和安卓端都是正常的,而在 iOS 端则会提示 Invalid Date 无效日期。在IOS年月日中间的横岗许换成斜杠,也就是new Date("2020/09/21 11:11:00")通常为了兼容IOS的这个坑,需要做一些额外的特殊处理,笔者在开发的时候经常会忘了兼容IOS系统。所以就想试着重写Date函数,一劳永逸,避免每次ne_date.prototype 将所有 ios

如何将EXCEL表导入plsql数据库中-程序员宅基地

文章浏览阅读5.3k次。方法一:用PLSQL Developer工具。 1 在PLSQL Developer的sql window里输入select * from test for update; 2 按F8执行 3 打开锁, 再按一下加号. 鼠标点到第一列的列头,使全列成选中状态,然后粘贴,最后commit提交即可。(前提..._excel导入pl/sql

Git常用命令速查手册-程序员宅基地

文章浏览阅读83次。Git常用命令速查手册1、初始化仓库git init2、将文件添加到仓库git add 文件名 # 将工作区的某个文件添加到暂存区 git add -u # 添加所有被tracked文件中被修改或删除的文件信息到暂存区,不处理untracked的文件git add -A # 添加所有被tracked文件中被修改或删除的文件信息到暂存区,包括untracked的文件...

分享119个ASP.NET源码总有一个是你想要的_千博二手车源码v2023 build 1120-程序员宅基地

文章浏览阅读202次。分享119个ASP.NET源码总有一个是你想要的_千博二手车源码v2023 build 1120

【C++缺省函数】 空类默认产生的6个类成员函数_空类默认产生哪些类成员函数-程序员宅基地

文章浏览阅读1.8k次。版权声明:转载请注明出处 http://blog.csdn.net/irean_lau。目录(?)[+]1、缺省构造函数。2、缺省拷贝构造函数。3、 缺省析构函数。4、缺省赋值运算符。5、缺省取址运算符。6、 缺省取址运算符 const。[cpp] view plain copy_空类默认产生哪些类成员函数

推荐文章

热门文章

相关标签