“Run the App” Exercise (Tic Tac Toe)

In this exercise, we’ll practice downloading, configuring, and running an existing Python application.

We’ll discuss topics related to command line computing, Anaconda virtual environments, Python package management, and environment variables.

Instructions

  1. Visit this “Tic Tac Toe” repository on GitHub. This repository contains a simple command-line game. We’ll refer to this repository as the “upstream” remote repository.
  2. Click the “Fork” button (top right of the page) to make a copy of the repo under your own control. We’ll refer to your forked copy as the “origin” remote repository.
  3. Follow the instructions in the repository’s “README.md” file to install, setup and run the Python code contained inside:
    1. Click the green button on GitHub to “Clone”, or download, your remote fork. Choose the GitHub Desktop option, selecting the “for my own purposes” option, if prompted by GitHub Desktop. When prompted where to download it, choose a familiar location like the Desktop. We’ll refer to this as the “local repository”.
    2. Use the finder or file explorer to verify you have downloaded the files and they exist, for example on your Desktop.
    3. Use the command-line to navigate to the local repository (using one or more cd commands).
    4. Use the conda utility to create a new virtual environment with the specified version of Python, then activate the virtual environment.
    5. Use the pip utility to install any required third-party packages specified in the repo’s “requirements.txt” file.
    6. Use the python utility to run the Python file(s) as described in the README’s “Usage” section.

Success Criteria

Once you have played a single game, you will have succeeded.

For fun, try replaying the game against different kinds of opponents (computer, human, etc.).

Further Exploration

Optionally simulate many games between computer players, and see the CSV file of game outcomes that gets produced.

Practice passing environment variables to customize the game count and player types.

Troubleshooting & Help

Here are some common errors you may run into while trying to run Python apps locally.

Bad Anaconda Installation

If you try to run a conda command, and you see an error like “conda: command not found”, it means there’s something wrong with your installation.

It’s OK. Feel free to reach out to an instructor and ask for help. See also these known troubleshooting remedies.

We will probably have to ask where anaconda in the Anaconda Prompt program to learn where your Anaconda installation resides, then issue a corresponding command like ~/anaconda3/Scripts/conda init bash in Git Bash to fix the issue. Then close and re-open Git Bash for the changes to take effect.

Can’t Install Packages / Forgot to Navigate to the Local Repo

If the pip install -r requirements.txt command throws an error like “Could not open requirements file: [Errno 2] No such file or directory”, make sure you are running it from the repository’s root directory, where the “requirements.txt” file exists (see the initial cd step to navigate into the repository’s root directory).

Forgot to Install Packages

If you see an error like “ModuleNotFoundError: No module named ‘…’”, it’s because the given package isn’t installed, so run the pip install -r requirements.txt command from the repository’s root directory to ensure that package has been installed into the virtual environment, before trying to run the app again.