Setting up Jupyter Notebook

Installing Python & Jupyter Notebook.

Intro

When you’re getting started working off platform you will find that there are a few steps to go through in order to explore Python and Jupyter Notebook locally. The first step is installation, which will require some knowledge about package managers and Python distributions. In order to install Python and Jupyter Notebook on your machine, you will need to work with the command line which comes in handy for moving around between files and folders in your file system.

What is a Python Distribution?

While Python itself is just a programming language, a Python distribution bundles the core language with various other libraries and packages generally geared toward a specific problem domain (such as Data Analytics or Web Development). The standard Python distribution is released on python.org and includes the Python Standard Library as well as the package manager pip. Though the list of Python distributions is always growing, two other popular distributions are Anaconda and Miniconda.

Anaconda vs. Miniconda

Anaconda is an open source Python distribution that is built for data science, machine learning, and large-scale data processing. While it is a very comprehensive distribution, it is also quite large and therefore can take a while to download and consumes a lot of disk space. Miniconda on the other hand, is a slimmed down version of Anaconda and includes all of the same components except for the pre-installed 1,500 data science packages. Instead, we can simply install these packages individually as needed using conda (the Anaconda/Miniconda package manager).

What is a Package Manager?

While the Python language is a great tool, a huge benefit of using Python is the large ecosystem and plethora of reusable packages (sometimes called libraries) that other developers maintain and share for anyone’s use. A package manager is the tool by which packages can be downloaded, installed, and managed within your projects. It is also responsible for keeping track of package versions and dependencies — packages that we don’t install ourselves but are imported by the package we’re installing. Even though a package manager is a complex tool, they are very simple to use. Each Python distribution is usually bundled with a specific package manager. Some of the more common ones are pip and conda.

Which Python Distribution Should I Install?

Good question! Now that the differences between Python distributions are clear, you are probably wondering which is the best distribution for you to install. There really is no right answer here, since each distribution is designed for varying needs. Regardless of what you decide, keep in mind that you really only need to install a single Python distribution (and not several). So, select your pick below and follow the corresponding installation instructions. Also keep in mind that there are a handful of different ways to install each of these Python distributions. However, the instructions below are the easiest way to get started!

Installing Python

Mac


Most modern versions of MacOS come pre-installed with Python 2, however Python 3 is now the standard and should be installed as well. Python 3 can be installed using the official Python 3 installer.

  • Go to the Python Releases for Mac OS X page and download the latest stable release macOS 64-bit/32-bit installer.
  • After the download is complete, run the installer and click through the setup steps leaving all the pre-selected installation defaults.

Once complete, we can check that Python was installed correctly by opening a Terminal and entering the command python3 --version. The latest Python 3.7 version number should print to the Terminal.

Advanced

Since our system now has both Python 2 (which came pre-installed) and Python 3, we must remember to use the python3 command (instead of just python) when running scripts. If you would rather not have to remember the python3 command and just use python instead, then creating a command alias is your best bet.

  • Execute open ~/.bash_profile from a Terminal (if the file was not found, then run touch ~/.bash_profile first).
  • Copy and paste alias python="python3" into the now open .bash_profile file and save.

While we’re at it, go ahead and copy and paste alias pip="pip3" into the file as well in order to create an alias for the Python 3 pip package manager. Finally, restart the Terminal and run python --version. We should see the exact same output as running python3 --version.

Windows


Follow the steps below to install Python 3 on Windows.

  • Go to the Python Releases for Windows page and download the latest stable release Windows x86-64 executable installer.
  • After the download is complete, run the installer.
  • On the first page of the installer, be sure to select the “Add Python to PATH” option and click through the remaining setup steps leaving all the pre-select installation defaults.

Once complete, we can check that Python was installed correctly by opening a Command Prompt (Open the Start Menu and type CMD or PowerShell) then entering the command python --version. The latest Python 3.7 version number should print to the console.

Installing Miniconda

Mac


Follow the instructions below to install the latest Miniconda version for Mac.

  • Go to the Miniconda Download page and download the Python 3.7 Mac OS X 64-bit .pkg installer.
  • After the download is complete, run the installer and click through the setup steps leaving all the pre-selected installation defaults.

Once complete, we can check that Miniconda was installed correctly by opening a Terminal and entering the command conda list. This will print a list of packages installed by Miniconda.

Windows


Follow the instructions below to install the latest Miniconda version for Windows.

  • Go to the Miniconda Download page and download the Python 3.7 Windows 64-bit .exe installer.
  • After the download is complete, run the installer and click through the setup steps leaving all the pre-selected installation defaults.

Once complete, we can check that Python was installed correctly by opening a Command Prompt (Open the Start Menu and type CMD or PowerShell) then entering the command conda list. This will print a list of packages installed by Miniconda.

Installing Jupyter Notebook

Now that we have a Python distribution installed and were able to run some Python code, let’s install the Jupyter Notebook package. Jupyter Notebook is an open-source web application that allows us to create and share documents that contain live code, equations, visualizations and narrative text. The installation steps differ depending on which Python distribution we installed above, so be sure to jump to the appropriate section. If you have both pip and Miniconda installed, we recommend using Miniconda to install the Jupyter Notebook package.

Using Miniconda


Follow the instructions below to install the Jupyter Notebook package using the Miniconda package manager conda.

  • Open a new Terminal (Mac) or Command Prompt (Windows).
  • Run conda install jupyter to download and install the Jupyter Notebook package.

Once complete, we can check that Jupyter Notebook was successfully installed by running jupyter notebook from a Terminal (Mac) / Command Prompt (Windows). This will startup the Jupyter Notebook server, print out some information about the notebook server in the console, and open up a new browser tab to http://localhost:8888.

Using Standard Python


Follow the instructions below to install the Jupyter Notebook package using the pip Python package manager.

  • Open a new Terminal (Mac) or Command Prompt (Windows).
  • Run pip install jupyter to download and install the Jupyter Notebook package.

Once complete, we can check that Jupyter Notebook was successfully installed by running jupyter notebook from a Terminal (Mac) / Command Prompt (Windows). This will startup the Jupyter Notebook server, print out some information about the notebook server in the console, and open up a new browser tab at http://localhost:8888.