Python and Jupyter Notebook Installation
Python and Jupyter Notebook Installation
1. Python
For this course, we will install Python through an open-source data science package
management system called conda. It is developed by Anaconda, Inc. and runs on
Windows, macOS and Linux.
We recommend downloading Miniconda for its lean setup, it contains all the
essential tools required for this course. Additional Python packages can be easily
installed using the conda or pip package managers.
Once you have the installation file downloaded to your computer, follow the below
operating system specific instructions.
Verify Installation:
● Open Anaconda prompt from Windows Start menu.
● Enter conda list to check if conda is installed and working, this will display a
list of installed packages and their versions.
● Enter the command python. This command runs the Python shell. If conda is
installed and working, the version information it displays when it starts up will
include Anaconda. To exit the Python shell, enter the command quit().
Installation Steps: macOS
● Miniconda has two types of installation files for macOS:
○ Package file (.pkg) for GUI based installation
○ Shell file (.sh) for installation through Terminal
● Download either of these file types based on your preference.
● Choose the default option Just Me on the Destination select window, this is
important if you do not have the administrator privileges for the computer. The
default installation
path for GUI based installation is at /Users/<your-username>/opt folder.
● Continue through the installation and close the installation window once complete.
Terminal Installation:
● Open the Terminal and navigate to the folder where the installation file is downloaded
to.
● Run the bash command followed by the filename
like: bash Miniconda3-latestMacOSXx86_64.sh
● Follow through the screen prompts and agree to license terms by entering yes
● Next, select the default installation location by pressing ENTER key. Unlike the
.pkg file, the default path for shell installation is at: //Users/<your-username>
● The installer prompts “Do you wish the installer to initialize Miniconda3 by
running conda init?” Type yes.
b. For example, enter the following command to install NumPy package: pip
install numpy. This will download and install the package.
2. Jupyter Notebook
Jupyter supports interactive data science and scientific computing across multiple
programming languages. There are two types of Jupyter software:
Jupyter Notebook: open-source web application that allows you to create and
share documents that contain live code, equations, visualizations and narrative
text.
JupyterLab: web-based interactive development environment for Jupyter
notebooks, code, and data. JupyterLab will eventually replace the classic
Jupyter Notebook.
You can start working with Jupyter Notebook and as you get comfortable using it,
you can move on to JupyterLab later.
● You can either browse to your desired directory using the Jupyter interface or
navigate to the directory in the command prompt prior to launching Jupyter
notebook.
● To create a new notebook, select Python 3 option under New menu.
● As a notebook opens in the new tab, make sure to select the code option
to execute Python script. You can add text to the notebook using
markdown option.
● To save a notebook to pdf, select File menu > Download as and click on PDF
via HTML option.
Python Package Management:
A Python package or library is a collection of modules, functions and methods that
allows for a minimal use of code during development. There are several useful data
science packages for Python and we will work with a few of them in this course.
Installing a package is quite similar to the Jupyter installation you have just done. In
general packages are installed through package managers like conda and pip. Just
specifying the command conda install <package_name> in the Command Prompt and it
will install that package if it exists in conda’s repository. If not you can always use pip
install <package_name>, which is in fact the most famous and widely used package
management system for Python.
Let us go over an example and install NumPy package using conda. In Command Prompt:
● conda install numpy will install the NumPy package in your environment
● Use conda list command to verify the installation or to list all packages in
your environment
● You can install a specific version of the package limited to your
environment by specifying the version number like conda install
numpy==1.18.1
● conda update numpy will update the NumPy package to the latest version
● Finally to uninstall the package, use the command conda remove numpy
As we are primarily using the conda package manager, use pip only as an
alternative, that is if a package is not found through one of the conda’s channels.