Python Dev Setup
Welcome to <INSERT COURSE USING PYTHON HERE>! This page has setup instructions for the various technologies that we will need for assignments and exercises in each course.
Depending on which course you're first reading this tutorial within, you may or may not have completed certain steps -- feel free to jump around to only those components you're missing.
We will complete tutorials with how to use each of the following in-class and through assignments, but having them downloaded in advance will make the most out of your time in class.
Setup Git & GitHub
If you haven't already, sign up for GitHub here
-
Note that Git has deprecated password authentication and requires you to authenticate using either ssh keys or auth tokens!
Even if you used GitHub in the past, you will need to configure a new authentication method such as here.
Download the
git
terminal tools here.If you are using a Windows computer, make sure to install Git Bash as part of the installation process in the above -- you'll use this instead of the basic command line for your terminal, as it just tends to work better for our objectives.
Open a new terminal/git bash window and type
git
and enter -- if you see a bunch of options pop up, you're good to go!
Install Python
-
Start by downloading the latest version of Python here:
-
Open a terminal and verify the installation by typing
python --version
orpython3 --version
, which should show you the version number of Python that you just installed.If you had an existing terminal open before downloading Python, open a new one to refresh the path.
Download Dependencies
-
We will be using the
pytest
library to run unit tests, especially for making sure that your implementations of assignments are efficient / don't have any infinite loops / recursion. Install using the instructions here (most simple way, by opening a terminal and typingpip install pytest
):
Important: a related dependency will make sure that your tests run efficiently / within the time allowed by the unit tests. You should also install the
pytest-timeout
package for this:pip install pytest-timeout
-
For classes requiring it, we will be using type annotations in Python, which will be checked / enforced via the
mypy
library, which can be downloaded here (most simple way, by opening a terminal and typingpip install mypy
):
Having trouble finding pytest and mypy in the terminal? This usually happens if you have multiple versions of Python installed. A couple of things to try:
Trying to run these in an IDE like VSCode? Don't. Instead, switch to an external terminal like Terminal on Macs and GitBash on Windows machines.
Do you have the
python3
alias mapping to your Python 3.X version? You might need to instead install viapip3 install pytest pytest-timeout mypy
and then execute usingpython3
If all else fails, you can always directly invoke the libraries via the -m parameter, e.g.,
python -m mypy
andpython -m pytest
(or, in the case of the bullet above, usepython3 -m mypy
etc.)
You should always verify that
mypy
andpytest
are correctly installed by opening a terminal and typing these executables to see if they're found.
Install an IDE
An Integrated Development Environment (IDE) is a program that bundles many helpers for software development, including: language-specific text editors, compiler warnings, code suggestions, debuggers, unit-test integration, and much more!
There are many IDEs that are suitable for Python development; in fact, even simple text editors like Sublime or Notepad++ are fine for editing Python source and then executing at the terminal.
-
That said, Visual Studio Code (VSCode) is the current IDE-du-jur for Python development and can be obtained here:
-
Install the Python Extension in VSCode following its tutorial here:
-
Install any necessary test Extensions in VSCode following its tutorial here:
Warning: Many VSCode plugins for some of the class' dependencies (e.g., mypy) are buggy and hard to configure. ALWAYS run your submissions at the terminal at least once before submitting to double check your work.