How to change a virtual environment while using jupyter lab?

Question

  1. How can I change my environment from the base (root) environment to newly created environment while using jupyter lab?
  2. How can I change the ‘root’ environment, where the jupyter lab is activated?

More in Detail

  • I haven’t used virtual environments much, so I am novice. Please bear with me even if my question sounds stupid.
  • Let me tell you the process of what I did, so that you can find out which step in the process is problematic for me.

1) Creation of a virtual environment in Anaconda Navigator

  • I created another virtual environment called testing because some libraries have crushed with each other in the base (root) environment.
  • I created the testing environment in the anaconda navigator, because it is much simpler to create a virtual env on anaconda navigator than console, because anaconda navigator is GUI.

2) After opening up jupyter lab, I cannot change the virtual environment

  • After I open up jupyter lab by typing jupyter lab in cmd, it seems like there is no way to change my environment, from base (root) to testing, which I created.
  • How can I change the virtual environment after executing the jupyter lab?

3) What to do if I want to start the jupyter lab from the testing environment?

  • How can I change the root environment, so that the testing environment is a basic environment that the jupyter lab starts with?

@krassowski Any suggestion, please?

  1. How can I change my environment from the base (root) environment to newly created environment while using jupyter lab?

You may be interested in GitHub - Anaconda-Platform/nb_conda_kernels: Package for managing conda environment-based kernels inside of Jupyter

As for other questions these look like basic questions about using conda; I would recommend reading through the conda User Guide (User guide — conda 4.10.3.post47+e6936a3d documentation). As for Anaconda Navigator - I never used it myself so cannot help here; it is a commercial product and they offer some support - see Help and support — Anaconda documentation.

However, there is some exciting work on JupyterLab Desktop support for virtual environments. Stay tuned.

2 Likes

Thank you @krassowski . However, the nb_conda_kernels does not seem to relate to my question, because it is about kernels, not the environment. The github repo of the library says as follows
This extension enables a Jupyter Notebook or JupyterLab application in one conda environment to access kernels for Python, R, and other languages found in other environments.

What I wanted to do was, when my root environment and another environment are both python kernels, I wanted to change the environment so that each environment can be used for a single purpose. For example, environment A is for data analysis while the environment B is for developing a web-page. Both A and B are using Python kernels.

Even in my example above, do you think the nb_conda_kernels has something to do with my question?

You can either have JupyterLab installed in a single environment and swap kernels coming from different environments, or have JupyterLab installed in each environment and spawn it from each environment separately, but hot swapping environments with JupyterLab itself is not supported, nor can I see any advantage over the other options available.

1 Like