Starting Up

You will be using Python 3, Jupyter notebooks, and several python modules (like Numpy and Scipy) in this course.

If you are new to python, here are some pointers for you to explore outside of class meetings:

  • A good starting point is the Python tutorial from the inventor of Python (who is also quite a character--you can get to know more about him at his webpage).

  • The author of the textbook for this course, Jake VanderPlas, has another book A Whirlwind Tour of Python which introduces python without a data science focus.

During the first class meeting or before it, we want to have everyone set up properly with a python environment for scientific computing. Please follow the instructions below to do so.

Python 3 vs. Python 2

Most operating systems (except Windows) already come with python installed. But the command python may be linked to Python 2 or Python 3 on your system. Your first task is to determine which.

Type python into a terminal. If you have python, the terminal will become an interactive python shell where the python version is printed. If the version starts with 3. you have Python 3. If your version number starts with 2. then your python command calls Python 2. We will not use Python 2 in this course.

If python on your command line gives you an error message or runs Python 2, please check to see what you get when you type python3 into the terminal. In some systems, Python 3 is accessed using the python3 command. If you don't have Python 3, then you will need to install it either from https://www.python.org or using the prepackaged distribution https://www.anaconda.com, as described in detail below.

Once you have Python 3, make sure you know how to access it in your system, either by the python or by the python3 command.

Now that you know whether or not you have Python 3 already installed, continue on to read about the two requirements you should satisfy for being in this course. Your second task is to ensure you can meet these requirements.

Two requirements

To proceed with this course, in addition to Python 3,

  • you need to have a working Jupyter installation, and
  • you need a mechanism to install a missing python module when needed.

These requirements can be met in at least the following two ways:

  • Option 1: Install the prepackaged distribution Anaconda, which includes Python 3, Jupyter as well as many other python packages we will use in this course. (Even if you already have Python 3 installed, Anaconda will install its own Python 3, accessible within Anaconda.)

  • Option 2: Install Python 3, then install python's own package manager called pip or pip3 (the latter is likely the case if python3 is the command you use to access Python 3), and then install Jupyter following their instructions online .

(There are further options to meet these requirements, but to limit the complexity of this discussion, we will focus on just these two options.)

Installation videos prepared for this course (linked below) and the following sections describe in detail how to proceed with Option 1 or Option 2. (Most of the installation problems arise when you already have a pre-existing python distribution whose paths spill over into a new installation, so if at all possible, remove any previous installations and start with a fresh install process, selecting one of the two options expanded on below.)

Option 1: Install Anaconda

Install the Anaconda distribution (select Python 3.7) from https://www.anaconda.com/distribution/. Instructions there are self-explanatory for Mac OS X and Linux operating systems -- for trouble shooting or further information please consult https://docs.anaconda.com/anaconda/. (If you have the Windows operating system, you may also choose to follow the detailed instructions below prepared for this course by graduate student Ben Parker.) Once you have installed Anaconda, please make a new environment for this course, wherein you will install packages as you need. Instructions for this on all operating systems are similar and are below after the section on Windows installation instructions.

Instructions for Installing Anaconda on Windows

Please either watch the video Anaconda_Windows_Install and/or follow the step by step instructions below for installing Anaconda on Windows.

  1. Visit the Anaconda distribution site: https://www.anaconda.com/distribution/

  2. Click the link for "64-Bit Graphical Installer (466 MB)" under "Python 3.7 Version"

  3. Select "Save File" and wait for the download to complete.

  4. When the download has finished, run the executable file that you downloaded.

  5. Follow the instructions for installing Anaconda. (When you are prompted to add Anaconda3 to your PATH environment variable and Register Anaconda3 as your default Python 3.7, leave both boxes unchecked and click Install.)

Double check you have Jupyter

  1. Press the Windows key and type Anaconda Navigator

  2. Select the Anaconda Navigator App.

  3. When the App has opened, press "Launch" under Jupyter Notebook.

Using the anaconda prompt

  1. Press the Windows key and type in Anaconda Prompt

  2. Select Anaconda Prompt

  3. With the Anaconda Prompt open, let's test your python installation. Type python followed by the enter key. You should see something like the following:

     Python 3.7.6 (default, Jan  8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
     Type "help", "copyright", "credits" or "license" for more information.
     >>>
  4. To exit python, you can either press ctrl+Z or type exit() and then press enter.

  5. You can also launch jupyter notebook by typing the following command into the Anconda prompt:

    jupyter-notebook

Create a new environment in Anaconda

  1. In the Anaconda Navigator, click Environments.

  2. Click the "+" button at the bottom of the window to create a new environment.

  3. Give the environment a new name, such as mth271_env

    3a. Make sure only Python has the checkbox next to it filled out.

    3b. Make sure the Python version is selected to be 3.7 in the adjacent dropdown box.

    3c. Click Create

  4. When the environment has been created, it should appear above. Click it.

  5. Next, proceed to install all the packages you need for the course. As an example, let us first describe installation of the geopandas package.

    5a. On the right, use the dropdown menu to select Not Installed

    5b. In the Search Packages box on the right, type in geopandas

    5c. Click the checkbox next to geopandas

    5d. Click Apply in the lower right-hand corner.

    5e. Click Apply once it appears in the Install Packages dialog box.

  6. You will need to repeat step 5 for at least for the following packages to run the course materials today.

    6a. git

    6b. gitpython

    6c. matplotlib

    6d. descartes

  7. Click Home (on the left) in Anaconda Navigator.

  8. Click Install for the following applications:

    8a. Jupyter Notebook

    8b. CMD.exe Prompt (only if you are on Windows)

    8c. Spyder

    8d. Qt Console

  9. To continue using mth271_env whenever you run Anaconda Navigator, go to Environments and click mth271_env whenever running the Anaconda Navigator. Then you can run applications in this environment from the Home menu.

Option 2: Install pip and jupyter

This option is a more hands-on approach, where you install only packages you want instead of an entire distribution. (Select this option only if you are an enthusiast/expert and know what you are doing.)

There are two videos available to guide you with this option:

  • If you using the Ubuntu Linux operating system, follow the video guide LinuxStartUp

  • If you using Mac OS X operating system, follow the video guide MacStartUp

None of the above works for you?

As a failsafe option (not a preferred option), if none of the above works on your system, you can attempt to use a virtual machine. We have prepared a platform-independent Linux Virtual Box, which you can download (huge file) from this Google Drive folder. Within the folder you will also find a text file with instructions on how to use it if your computer runs Windows. If you have a different operating system, please follow the instructions at Oracle WM Virtual Box to install Virtual Box, and then import the .ova file from the Google drive. Once you have this virtual machine running, you get a window which emulates a linux box, and you can proceed as in the video LinuxStartUp.

If the virtual box also does not work for you, or if you have somehow not met the above-mentioned two requirements by the end of the first week of classes, you are strongly recommended to drop this course.