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

后端 未结 1 493
南笙
南笙 2020-12-15 14:08

When a conda environment is activated in a shell window, the environment is only active in that window (i.e. not persistent). So when I navigate to the project location in a

相关标签:
1条回答
  • 2020-12-15 14:54

    Register a (python) notebook kernel:

    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.

    Installing and registering a python kernel in the environment will make it available over the graphical notebook interface.

    To do so, first install the ipython kernel:

    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. If you select it, all packages installed into juypter-env35 will be available.

    Unregister a notebook kernel:

    If you want delete the kernel from the notebook interface, jupyter --data-dir, will print out jupyter's data directory.

    Navigate to the printed folder, find the subfolder kernels and delete the folder with the name of your kernel (here jupyter-env35). After that the kernel will not show up in jupyter anymore.

    0 讨论(0)
提交回复
热议问题