Summary and Setup
ATTENTION This is an experimental test of The Carpentries Workbench lesson infrastructure. It was automatically converted from the source lesson via the lesson transition script.
If anything seems off, please contact Zhian Kamvar zkamvar@carpentries.org
This lesson is an introduction to programming in Python for librarians with little or no previous programming experience. It uses examples that are relevant to a wide range of library use cases, and is designed to be used as a prerequisite lesson for other Python based lessons that will be developed in the future, e.g. using the Pandas for data analysis.
This lesson references the Spyder IDE, but can be taught using a regular Python interpreter as well. Please note that this lesson uses Python 3 rather than Python 2.
Under Design
This lesson is currently in its early design stage; please check the design notes to see what we have so far. Contributions are very welcome: we would be particularly grateful for exercises and for commentary on the ones already there.
Prerequisites
Learners need to understand what files and directories are, what a working directory is, and how to start a Python interpreter from a terminal window.
Learners must install Anaconda before the class starts.
Please see the setup instructions for details.
Installing Python Using Anaconda
Python is great for general-purpose programming and is a popular language for scientific computing as well. Installing all of the packages required for this lessons individually can be a bit difficult, however, so we recommend the all-in-one installer Anaconda.
Regardless of how you choose to install it, please make sure you install Python version 3.x (e.g., Python 3.6 version). Also, please set up your Python environment at least a day in advance of the workshop. If you encounter problems with the installation procedure, ask your workshop organizers via e-mail for assistance so you are ready to go as soon as the workshop begins.
Windows - Video tutorial
Open anaconda.com/download with your web browser.
Download the Python 3 installer for Windows.
Double-click the executable and install Python 3 using MOST of the default settings. The only exception is to check the Make Anaconda the default Python option.
macOS - Video tutorial
Open anaconda.com/download with your web browser.
Download the Python 3 installer for macOS.
Install Python 3 using all of the defaults for installation.
Linux
Note that the following installation steps require you to work from the shell. If you run into any difficulties, please request help before the workshop begins.
Open anaconda.com/download with your web browser.
Download the Python 3 installer for Linux.
Install Python 3 using all of the defaults for installation.
Open a terminal window.
Navigate to the folder where you downloaded the installer
Type
and press tab. The name of the file you just downloaded should appear.
Press enter.
Follow the text-only prompts. When the license agreement appears (a colon will be present at the bottom of the screen) hold the down arrow until the bottom of the text. Type
yesand press enter to approve the license. Press enter again to approve the default location for the files. Typeyesand press enter to prepend Anaconda to yourPATH(this makes the Anaconda distribution the default Python).
Starting Python
We will teach Python using Spyder. If you installed Python using Anaconda, Spyder should already be on your system. If you did not use Anaconda, use the Python package manager pip (see the Spyder website for details.)
To start Spyder, open a terminal or Git Bash and type the command:
To start the Python interpreter without Spyder, open a terminal or Git Bash and type the command: