Course Setup
Do this before the first lab. The course uses three tools: VS Code, the editor you will write every assignment in; Git, the program on your computer that records and sends your changes; and GitHub, the website that keeps a copy of each assignment. This page installs the first two, creates an account for the third, and connects them. Budget about half an hour. If you get stuck, bring your laptop to class or office hours and show me the step you were on and the exact message.
Install VS Code
Download Visual Studio Code and install it like any other program. On macOS, drag it into your Applications folder before opening it. Open it and leave it open; the next steps use it.
Install Git
Follow the instructions for your operating system.
macOS
First install Homebrew, a package manager that installs programs from the terminal. You will use it for Git now and Python in the Python reading. In VS Code, choose Terminal → New Terminal. A panel opens at the bottom of the window where you can type commands. Paste the Homebrew installation command into it and press Enter:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"Follow the prompts, including installing Apple’s Command Line Tools if requested. If it asks for a password, type the password you use to log in to your Mac and press Enter; no characters appear while you type. The installation can take several minutes.
When it finishes, look for Next steps in the terminal output. Copy and run each command it lists for adding Homebrew to your PATH, one line at a time. These commands let the terminal find brew; use the ones the installer prints for your Mac. Check that Homebrew is ready:
brew --versionIt should print a version number. Then install Git with Homebrew:
brew install gitWindows
Download Git for Windows and run the installer. Keep the default choice on every page and click Next until it finishes.
Linux
Install the git package with your distribution’s package manager. On Ubuntu or Debian:
sudo apt install gitCheck Git
Quit VS Code completely and open it again so it notices the new program. To check that Git is installed, choose Terminal → New Terminal and type:
git --versionIt should print a version number.
Create a GitHub Account
Sign up at https://github.com/signup and verify your email address when GitHub sends the message. Your username will appear on everything you publish in this course, so choose one you would put on a resume. If you already have an account, use it.
Sign In to GitHub From VS Code
Signing in once lets VS Code download your repositories and send your changes back without asking for a password each time.
- Click the Source Control icon in the bar on the left side of VS Code. It looks like a branching line.
- Click Clone Repository, then choose Clone from GitHub.
- VS Code asks permission to sign in with GitHub, then opens your browser. Sign in, click Authorize, and allow the browser to open VS Code when it asks.
- Back in VS Code, a search box for your repositories appears. You have nothing to download yet, so press Esc to close it.
Tell Git Your Name
Git labels every change you save with a name and an email address, and it will not save one until it has them. In the VS Code terminal (Terminal → New Terminal), run these two lines with your own name and the email address on your GitHub account:
git config --global user.name "Your Name"
git config --global user.email "you@example.com"Nothing prints when they succeed.
Make a Course Folder
In Finder or File Explorer, create a folder named csci40 inside your Documents folder. Each assignment will get its own folder inside it. The first reading opens this folder in VS Code, and the first lab shows how to download an assignment into it.
Python Environments
Use this section when a reading, lab, or project asks you to install Python libraries. First install Python if you have not already done so. A virtual environment keeps one project’s installed libraries separate from the others.
Open the project folder in VS Code and choose Terminal → New Terminal. Create the environment once per project:
python3 -m venv .venvOn Windows, use python if python3 is unavailable. If this project already has an environment, reuse it.
Activate It in Each Terminal
Run the command for your terminal from the project folder:
| Terminal | Command |
|---|---|
| macOS or Linux | source .venv/bin/activate |
| Windows PowerShell | .venv\Scripts\Activate.ps1 |
| Windows Command Prompt | .venv\Scripts\activate.bat |
| Windows Git Bash | source .venv/Scripts/activate |
If PowerShell blocks activation, open a Command Prompt terminal in the same folder and use its command. An older project may call its environment venv; use that name in place of .venv in the activation command.
Activation makes python use this environment’s interpreter. Check which interpreter is active:
python -c "import sys; print(sys.executable)"The printed path should contain your project’s .venv (or venv) folder. Activate again whenever you open a new terminal for this project.
Install the Project’s Libraries
Return to the assignment and run its installation command. python -m pip installs packages for the same interpreter that runs your code. When the assignment supplies a requirements.txt file, the command is:
python -m pip install -r requirements.txtIf you see externally-managed-environment, activate the project’s environment and retry. Keep .venv/ (or venv/) in .gitignore; the installed environment stays on your computer. To leave it, run deactivate or close the terminal.
Troubleshooting
On macOS, brew says the command was not found. Run the commands under Next steps at the end of the Homebrew installation, then quit and reopen VS Code and try a new terminal.
git --version says the command was not found, or VS Code says Git is missing. Quit VS Code completely and open it again, then try a new terminal. On Windows, also confirm that the Git installer finished.
The browser signed you in, but VS Code shows no search box. Try Clone Repository → Clone from GitHub once more. If the browser signed in to a different account, sign out of GitHub in the browser and repeat.
Something else. Post the step you were on and the complete message on Discord, or bring your laptop to class.