简体   繁体   English

如何使conda虚拟环境持久且可用于Jupyter Notebook等工具?

[英]How to make conda virtual environments persistent and available for tools such as Jupyter Notebook?

When a conda environment is activated in a shell window, the environment is only active in that window (ie not persistent). 在外壳程序窗口中激活conda环境时,该环境仅在该窗口中处于活动状态(即非持久性)。 So when I navigate to the project location in another window, the "root" virtual environment is active. 因此,当我在另一个窗口中导航到项目位置时,“根”虚拟环境处于活动状态。

Am I missing something or is this the intended behaviour? 我是否缺少某些东西,或者这是预期的行为?

How to give tools such as Jupyter Notebook access to the created environment? 如何让Jupyter Notebook等工具访问所创建的环境?

Register a (python) notebook kernel: 注册一个(python)笔记本内核:

Let's suppose you have created a conda environment named jupyter-env35 with conda create -n jupyter-env35 python=3.5 and now want to use it in jupyter. 假设您已经创建了一个名为jupyter-env35环境, jupyter-env35 conda create -n jupyter-env35 python=3.5 ,现在想在jupyter中使用它。

Installing and registering a python kernel in the environment will make it available over the graphical notebook interface. 在环境中安装和注册python内核将使其在图形笔记本界面上可用。

To do so, first install the ipython kernel: 为此,请先安装ipython内核:

conda install -n jupyter-env35 ipykernel

Then activate the environment and register the kernel: 然后激活环境并注册内核:

source activate jupyter-env35
ipython kernel install --user --name jupyter-env35

When you now fire up juypter, it will show jupyter-env35 as a kernel in the list of available kernels. 现在启动juypter时,它将在可用内核列表中将jupyter-env35显示为内核。 If you select it, all packages installed into juypter-env35 will be available. 如果选择它,则安装在juypter-env35所有软件包都将可用。

Unregister a notebook kernel: 注销笔记本内核:

If you want delete the kernel from the notebook interface, jupyter --data-dir , will print out jupyter's data directory. 如果要从笔记本界面删除内核, jupyter --data-dir将打印出jupyter的数据目录。

Navigate to the printed folder, find the subfolder kernels and delete the folder with the name of your kernel (here jupyter-env35 ). 导航到打印的文件夹,找到子文件夹kernels然后删除带有您内核名称的文件夹(此处为jupyter-env35 )。 After that the kernel will not show up in jupyter anymore. 之后,内核将不再显示在jupyter中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在我的 jupyter 笔记本上安装仅在 pip 上可用而不在 conda 上可用的包? - How to install a package on my jupyter notebook that is only available on pip and not in conda? Jupyter Notebook 不再识别新的 conda 环境 - New conda environments no longer being recognised in Jupyter Notebook 如何为打开的 jupyter notebook 切换环境 - How to switch environments for open jupyter notebook Jupyter notebook 无法从 nb_conda_kernels 找到 conda 环境的内核 - Jupyter notebook can't find kernels for conda environments from nb_conda_kernels 当我使用conda改变环境时,为什么“conda”或“jupyter notebook”不起作用? - Why doesn't 'conda' or 'jupyter notebook' work when I use conda to change environments? 将 python package 安装到 conda 虚拟环境,Jupyter Notebook 中的 ModuleNotFoundError - Installed python package to conda virtual environment, ModuleNotFoundError in Jupyter Notebook 在虚拟环境中安装 ipykernel 并运行 jupyter notebook - 不使用 conda - Installing a ipykernel and running jupyter notebook inside a virtual env - not using conda 如何将 R conda env 连接到 jupyter notebook - How to connect R conda env to jupyter notebook 如何在Jupyter Notebook中选择您的conda环境 - How to choose your conda environment in Jupyter Notebook 如何在 Jupyter Notebook 终端中激活 conda virtualenv? - How to activate a conda virtualenv in a Jupyter Notebook terminal?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM