A simple guide for creating Virtual Environment in Jupyter Notebook(Python) for Windows.
Sometimes there are situations where we need to develop our code in some different conditions according to some certain requirements. Like for example we are working on Python3 but in some cases we need to use Python2. Or we need to use some library that only support certain python version. We can also make our customized environment for particular needs and put all the required libraries installed in that environment only. Sometimes this turns out to be very helpful.
But creating it on jupyter notebook is not that smooth process which can work without error. This guide will help you to create your virtual enviornment in a simple way:-
(I am assuming that you have already using Anaconda based Jupyter Notebook environment, if not download it from here)
Now for creating virtual environment :-
- Make sure you have having good internet connectivity.
2. Open Anaconda Prompt (let’s assume we are making a virtual environment for python 3.5.0, naming it as ‘NewEnv’) and write-
conda create--name NewEnv python=3.5.0
let it download for sometime.
3. After that write :-
conda activate NewEnv
Now your new environment is successfully created and activated, it’s name is ‘NewEnv’.
4. Now after activating it, write:-
pip install ipykernel
5. Let it download and install for some time. Then after that write:-
python -m ipykernel install --user --name=NewEnv
Now the new environment has been installed in Jupyter notebook.
6. Install all the required libraries in your new environment.
7. To deactivate or get back to base environment, just write :-
8. Now check that your new virtual environment is installed in Jupyter Notebook or not.
If it is showing in the New option then it is successfully installed in your Jupyter Notebook.
9. If it is not showing then check all the steps and try again.
10. If you want to install any library in that environment, then just go to anaconda prompt, activate your environment (shown in step-3), then install your required library using ‘pip’ or ‘conda’. Then it will work fine.