How to switch environment on Jupyter notebook for new notebook?

python anaconda jupyter-notebook jupyter conda

15288 просмотра

3 ответа

1069 Репутация автора

I have an instance with various environment and some notebooks are compatible with different environment for e.g. notebook1 is for MXNet and notebook2 is for Tensorflow.

How do I jump to new environment when I move from notebook1 to notebook2? I tried doing that but this doesn't quite work with Jupyter notebook? Any suggestion?

So I need to do it from conda environment but looks like jupyter notebook UI doesn't respect (calls right activation function) to set the path.

Автор: rgaut Источник Размещён: 08.11.2017 11:11

Ответы (3)

1 плюс

667 Репутация автора

When you start a jupyter notebook within an environment, it will only have access to the modules installed in that particular enviroment. If you need two specific environments for two different notebooks, you will need to start a jupyter notebook within the two environments separately.

If you are using anaconda, you would do the following in a terminal:

source activate MXNET
jupyter notebook

Then in a second terminal:

 source activate Tensorflow
 jupyter notebook
Автор: Mark Hannel Размещён: 08.11.2017 11:35

7 плюса

491 Репутация автора

You could use the nb_conda_kernels package, which provides a separate jupyter kernel for each conda environment, along with the appropriate code to handle their setup. This makes switching conda environment as simple as switching jupyter kernel (e.g. from the kernel menu), which I find very convenient. You can get it from the conda-forge channel, using

conda install -c conda-forge nb_conda_kernels
Автор: jcb91 Размещён: 13.11.2017 11:05

0 плюса

1069 Репутация автора

Along with this package I think also need to change the ~/.jupyter/ file with following config

c.NotebookApp.kernel_spec_manager_class = 'environment_kernels.EnvironmentKernelSpecManager'
Автор: rgaut Размещён: 14.11.2017 02:51
Вопросы из категории :