How to create a new Conda environment and use it with Jupyter Notebook.

Muhammad Tariq
Analytics Vidhya
Published in
3 min readApr 26, 2020

Sometimes it becomes really hard to install some python packages inside the base environment. I came across one package named Geopandas. I wanted to visualize Covid-19 data on a map and required geopandas for that but installing it was so difficult that anaconda was stuck for hours trying to solve the environment. For moments like this, conda environments become handy. We can configure exactly what packages we need and make things work for us. In this tutorial, I’ll show you how to create a new Conda environment from scratch and then use it within Jupyter notebooks.

The first part is to navigate to the windows start menu. I am assuming here that you have already installed Anaconda Package Manager. If not, please use this link to download it. It’s a pretty straight forward process. Coming back, head to your start menu, and search for “Anaconda Prompt”. Since I’m using windows, all anaconda commands need to go through Anaconda Prompt. Please refer to the image below:

Establishing new Conda Environment using Anaconda Prompt

Upon clicking on “open”, “Anaconda Prompt” would open. Now we need to perform the following tasks one by one.

  1. Create a new Conda Environment.
  2. Activate the newly created conda Environment.
  3. Install the required packages.
  4. Create a kernel.
  5. Start Jupyter Notebook.

We would start obviously by creating a new Conda environment.

conda create --name Covid19

This code creates a new anaconda environment with the name “Covid19”. Moving on to activating this environment.

conda activate Covid19

This code activates the Conda environment named “Covid19”. Notice how the environment name changes from (base) to (Covid19) at the left. This indicates that our environment “Covid19” is now activated.

Now we need to install our required packages since I’m looking for Geopandas, I’ll go for Conda installing geopandas using the code below:

conda install -c conda-forge geopandas -y

This code would install geopandas in the environment. Now we are just left with starting kernels. We can do this by running the following commands.

conda install nb_conda_kernels -y

This should be pretty much it. The last process is just about starting the jupyter notebook. We can spin it by just typing

jupyter notebook

With this, a new Jupyter notebook should start and this time, the new tab should have a new kernel named “geopandas-env”. Click on this kernel and we have an environment with geopandas installed.

I really hope this would have helped. Happy coding.

If you are interested in to Covid19 global visualizations, please click here.

--

--

Muhammad Tariq
Analytics Vidhya

Data enthusiast transforming raw data into actionable insights. Skilled in Python, SQL, ETL, and Data Pipelines.