[英]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等工具访问所创建的环境?
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
所有软件包都将可用。
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.