本文介绍了如何在Jupyter Lab中添加Conda环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Jupyter Lab,无法添加conda环境.这个想法是从我的基本环境启动Jupyter Lab,然后能够选择我的其他conda env作为内核.

I'm using Jupyter Lab and I'm having trouble to add conda environment. The idea is to launch Jupyter Lab from my base environment, and then to be able to choose my other conda envs as kernels.

我安装了软件包nb_conda_kernels,该软件包本来可以做到的,但是它并没有按照我的意愿工作.确实,假设我创建了一个新的Conda Environment,然后从基础上启动了jupyter Lab,我无法将新环境视为可用的内核.

I installed the package nb_conda_kernels which is supposed to do just that, but it's not working as I want. Indeed, let's assume I create a new Conda Environment, then I launch jupyter lab from base, I can't see the new environment as an available kernel.

我找到了一个修复程序",该修复程序每次都可以运行,但是根本不方便.如果我在新环境中安装Jupyter Notebook,然后从此新环境中启动jupyter Notebook,将其关闭,返回到基础环境,然后从基础环境中启动Jupyter Lab,则我的新环境可以作为Jupyter Lab中的内核使用.

I have found a "fix", which works everytime but is not convenient at all. If I install Jupyter Notebook in my new environment, then launch a jupyter notebook from this new environment, close it, go back to base environment, and then launch Jupyter Lab from base environment, my new environment is available as a kernel in Jupyter Lab.

如果您知道如何在不使用此修复程序"的情况下运行它,我将非常感激.

If you know how to make it work without this "fix", I would be very grateful.

推荐答案

假设您的conda-env被命名为cenv,它很简单:

Assuming your conda-env is named cenv, it is as simple as :

$ conda activate cenv
(cenv)$ conda install ipykernel
(cenv)$ ipython kernel install --user --name=<any_name_for_kernel>
(cenv($ conda deactivate

如果重新启动jupyter笔记本/实验室,您将能够看到可用的新内核.

If you restart your jupyter notebook/lab you will be able to see the new kernel available.

PS:如果您使用的是virtualenv等,则上述步骤很有效.

PS: If you are using virtualenv etc. the above steps hold good.

这篇关于如何在Jupyter Lab中添加Conda环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-03 22:33