1

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.

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. I already tried installing nb_conda, nb_conda_kernels

1

2 Answers 2

1

install nb_conda and nb_conda_kernels into your base.

conda install nb_conda nb_conda_kernels -n env1

This should give you the ability to change kernel in jupyter, and use the env2 kernel.

Sign up to request clarification or add additional context in comments.

3 Comments

This does not work. In fact I already had these 2 packages from before.
Can you try listing kernelspecs? jupyter kernelspec list
python3 /home/ec2-user/miniconda3/envs/airflow3/lib/python3.6/site-p ackages/ipykernel/resources | airflow3 /home/ec2-user/.local/share/jupyter/kernels/airflow3 | data_interface /home/ec2-user/.local/share/jupyter/kernels/data_interface
0

I would install jupyter notebook in the base env (not env1, not env2) Then install nb_conda_kernels in the base

in env1 and env2, install ipykernel in env1 and env2, run this:

python -m ipykernel install --user --name env1 --display-name "env1 env"

Check this out for more info: New Conda environment with latest Python Version for Jupyter Notebook

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.