Summary and Setup

This lesson is an introduction to programming in Python for library and information workers with little or no previous programming experience. It uses examples that are relevant to a range of library use cases, and is designed as a prerequisite for other Python lessons that will be developed in the future (e.g., web scraping, APIs). The lesson uses the JupyterLab computing environment and Python 3.

Prerequisites

  1. Learners need to understand what files and directories are and what a working directory is.

  2. Learners must install Python and JupyterLab, and download the dataset that will be used in the lesson, before the workshop begins.

Please see setup instructions below for details.

Installing Python Using Anaconda


Python is a popular language for research computing, and great for general-purpose programming as well. Installing all of its research packages individually can be a bit difficult, so we recommend Anaconda, an all-in-one installer.

Regardless of how you choose to install it, please make sure you install Python 3.6 or above. The latest 3.x version recommended on Python.org is fine.

We will teach Python using JupyterLab, a programming environment that runs in a web browser (JupyterLab will be installed by Anaconda). For this to work you will need a reasonably up-to-date browser. The current versions of the Chrome, Safari and Firefox browsers are all supported (some older browsers, including Internet Explorer version 9 and below, are not).

Windows - Video tutorial

  1. Open anaconda.com/download with your web browser.

  2. Download the Anaconda for Windows installer with Python 3. (If you are not sure which version to choose, you probably want the 64-bit Graphical Installer Anaconda3-…-Windows-x86_64.exe)

  3. Install Python 3 by running the Anaconda Installer, using all of the defaults for installation except make sure to check Add Anaconda to my PATH environment variable.

macOS - Video tutorial

  1. Open anaconda.com/download with your web browser.
  2. Download the Anaconda Installer with Python 3 for macOS (you can either use the Graphical or the Command Line Installer).
  3. Install Python 3 by running the Anaconda Installer using all of the defaults for installation.

Linux

Note that the following installation steps require you to work from the shell. If you aren’t comfortable doing the installation yourself stop here and request help from the workshop organizers.

  1. Open anaconda.com/download with your web browser.

  2. Download the Anaconda Installer with Python 3 for Linux.

  3. Open a terminal window and navigate to the directory where the executable is downloaded (e.g., cd ~/Downloads).

  4. Type bash Anaconda3 and press Tab to auto-complete the full file name. The name of file you just downloaded should appear.

  5. Press Enter (or Return depending on your keyboard). You will follow the text-only prompts. To move through the text, press Spacebar. Type yes and press Enter to approve the license. Press Enter (or Return) to approve the default location for the files. Type yes and press Enter (or Return) to prepend Anaconda to your PATH (this makes the Anaconda distribution the default Python).

  6. Close the terminal window.

JupyterLab


We will teach Python using JupyterLab, a part of a family of Jupyter tools that includes Jupyter Notebook and JupyterLab, both of which provide interactive web environments where you can write and run Python code. If you installed Anaconda, JupyterLab is installed on your system. If you did not install Anaconda, you can install JupyterLab on its own using conda, pip, or other popular package managers.

Download the data


  1. Download this zip file and save it to your Desktop.
  2. Unzip the data.zip file, which should create a new folder called data.
  3. Create a new folder on your Desktop called lc-python and put the data folder in this folder.

This lesson uses circulation data in multiple CSV files from the Chicago Public Library system. The data was compiled from records shared by the Chicago Public Library in the data.gov catalog. Please do not download the circulation data from data.gov since the dataset you downloaded following the steps above has been altered for our purposes.