Jupyter Notebook的终端命令未使用正确的conda环境 [英] Jupyter Notebook's terminal command not using correct conda environment
问题描述
我安装了2个conda环境:
-env1
:安装jupyter-notebook并从其启动的基本环境
-env2
:安装了ipykernel的项目环境
我在此之后,手动添加了两种环境的内核规范指南.
I have 2 conda environments installed:
- env1
: base environment where jupyter-notebook is installed and started from
- env2
: project environment with ipykernel installed
I manually added kernelspecs for the 2 environments following this guide.
一切正常. 2个内核中的sys.executable
显示单独的正确路径.但是对于终端命令(即!which python
),无论我在环境中运行的哪个内核默认为env1
.
Everything works fine. sys.executable
in 2 kernels show separate, correct paths. But for terminal commands (i.e. !which python
), no matter which kernel I'm running in the environment defaults to env1
.
有什么方法可以使笔记本自动将其更改为内核环境?
Is there any way to have the notebook automatically change this to the kernel's environment?
P.S.我已经尝试安装nb_conda,nb_conda_kernels
P.S. I already tried installing nb_conda, nb_conda_kernels
推荐答案
将nb_conda和nb_conda_kernels安装到您的库中.
install nb_conda and nb_conda_kernels into your base.
conda install nb_conda nb_conda_kernels -n env1
这应该使您能够在jupyter中更改内核,并使用env2内核.
This should give you the ability to change kernel in jupyter, and use the env2 kernel.
这篇关于Jupyter Notebook的终端命令未使用正确的conda环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!