VSCode and Jupyter Notebooks: Automatic activation of virtual environment from selected kernel

Viewed 63

When working on a Python file with VSCode a new integrated terminal automatically activates the virtual environment from which I have chosen the Python interpreter. I find this to be very useful and I wanted to know if it's possible to do the same with Jupyter Notebooks.

If I select a specific virtual environment as my Jupyter kernel and open a new terminal, this will not activate the virtual environment. I thought there could be some command like "jupyter.terminal.activateEnvironment": true (if that makes sense?) but haven't been able to find anything.

Is there anything close to this? I'm very new to VSCode so some things I say might not be correct... Happy to learn more and thanks for any help!

1 Answers

What do you mean with "select a specific virtual environment as my Jupyter kernel"? The procedure to install Jupyter in an environment is documented here: Kernels for different environments

source activate myenv
pip install ipykernel
python -m ipykernel install --user --name myenv --display-name "Python (myenv)"

Finally, select the registered kernel "Python (myenv)" in VSCode and you're done.

Related