如何使conda虚拟环境持续存在并可用于Jupyter Notebook等工具?

Gre*_*reg 3 python ipython conda jupyter jupyter-notebook

当在shell窗口中激活conda环境时,环境仅在该窗口中处于活动状态(即不是持久的).因此,当我导航到另一个窗口中的项目位置时,"根"虚拟环境处于活动状态.

我错过了什么或者这是预期的行为吗?

如何让Jupyter Notebook等工具访问创建的环境?

cel*_*cel 8

注册一个(python)笔记本内核:

让我们假设你已经创建了一个名为康达环境jupyter-env35conda create -n jupyter-env35 python=3.5现在想在jupyter使用它.

在环境中安装和注册python内核将使其可通过图形笔记本界面使用.

为此,首先安装ipython内核:

conda install -n jupyter-env35 ipykernel
Run Code Online (Sandbox Code Playgroud)

然后激活环境并注册内核:

source activate jupyter-env35
ipython kernel install --user --name jupyter-env35
Run Code Online (Sandbox Code Playgroud)

当你现在启动juypter时,它将jupyter-env35在可用内核列表中显示为内核.如果选择它,juypter-env35则可以使用安装的所有软件包.

取消注册笔记本内核:

如果要从笔记本界面删除内核jupyter --data-dir,将打印出jupyter的数据目录.

导航到打印的文件夹,找到子文件夹kernels并删除包含内核名称的文件夹(此处jupyter-env35).之后,内核将不再出现在jupyter中.