How to install Jupyter Notebook using Anaconda Distribution
To work on a data science project, it’s essential to set your computer up correctly. This article will go through what Anaconda is, what is Minconda and what Conda is, and why you should know about them if you are a data science learner.
Whether you’re working solo or working in a team on a Data Science, Machine learning, and Deep Learning based project these tools provide the infrastructure for a consistent experience.
Anaconda, Miniconda, and Conda provide the ability for you to share the foundation on which your experiment is built and also ensure that if someone else wanted to reproduce your work, they’d have the same tools as you.
2. Download the appropriate Anaconda distribution for your computer. Unless you have a specific reason, it’s a good idea to download the latest version. In my case, I downloaded the Mac Python 3.8 64-bit Graphical Installer.
3. Once the download has been completed, double-click on the download file to go through the setup steps, leaving everything as default. This will install Anaconda on your computer. It may take a couple of minutes and you’ll need up to 3 GB of space available.
4. To check the installation, open Anaconda Prompt from the start menu. If it was successful, you’ll see (base) appear next to your name.
To see all the tools (packages) you just installed, type the code conda list and press enter.
What you should see are four columns. Name, version, build and channel.
Name is the package name. Remember, a package is a collection of code someone else has written.
Version is the version number of the package and build is the Python version the package is made for. For now, we won’t worry about either of these but what you should know is some projects require specific versions and build numbers.
Channel is the Anaconda channel the package came from, no channel means the default channel.
Environment Creation :
It is a good practice to create a new environment for each new project. To create a new environment, you can type:
conda create --name envName python
Now a new environment is created with this name — envName
This way (without mentioning the python version in the command), an environment with the latest version of python is created.
But if you need a particular version of python, let’s say 2.7, use the following command.
conda create --name envName python=2.7
Environment Activation :
Now you have the environment created as per your need.
To work in that environment, you need to activate it.
Use the following command.
conda activate envName
Okay, now we know we have Anaconda installed, let’s install packages that are specific to your project in this environment using conda install PackageName
After doing some research, you find the tools (packages) you’ll need are:
Jupyter Notebooks — for writing Python code, running experiments, and communicating your work to others.
NumPy — for performing numerical operations on data.
Matplotlib — for creating visualizations of your findings.
scikit-learn — also called sklearn, for building and analyzing machine learning models.
If you’ve never used these before, don’t worry. What’s important to know if you’ve followed the steps above and installed Anaconda, these packages have been installed too. Anaconda comes with many of the most popular and useful data science tools right out of the box. And the ones above are no exception.
Using conda env list command, you can find a list of all the environments created. You can differentiate the active environment by seeing an asterisk (‘*’) in that list.
Make application dependencies available in the different environments :
When working on a group project, to execute the project on your teammate’s system you need the same dependencies. In that case, you can create a requirements.txt file.
Today the most used Python package manager is pip, used to install and manage python software packages, found in the Python Package Index. Pip helps us, python developers, effortlessly “manually” control the installation and lifecycle of publicly available Python packages from their online repositories.
Actions will be similar to the one below:
Create a virtual environment
Install packages using $pip install <package> command.
Save all the packages in the file with pip freeze > requirements.txt. Keep in mind that in this case, the requirements.txt file will list all packages that have been installed in the environment, regardless of where they came from.
When if you’re going to share the project with the rest of the world you will need to install dependencies by running $pip install -r requirements.txt
Environment Deactivation :
If you wish to deactivate the current environment, use the following command.
After executing the above command, the current environment is deactivated and the base environment is activated.
Note: Deactivating doesn’t delete the environment.
Environment Removal :
If you want to delete an environment, use the following command.
conda env remove — name envName
Using the above command you can delete envName the environment. For this command to work, envName shouldn’t be in the active environment.
There’s much more you can do with Anaconda, Miniconda, and Conda and this article only scratch the surface.