Computing Setup Guide

Python, VSCode, and Related Tools

This document will guide you through setting up your machine for success in CS 307.

We understand that you very likely have a setup that you have used in previous courses. However, we still recommend you follow this guide to avoid issues that could arise.

Install Python

First and most importantly, you will need to install Python. You probably already have Python installed, but we’d like you to install a specific version, via a specific method.

We recommend installing Python directly from www.python.org. Yes, this might add another version of Python to your machine, but it will be worth it.

On the above page, your OS should be automatically detected, and you can use the “Download Python 3.12.5” button. Version 3.12.5 is the latest at the time of writing this document, and what you should use for CS 307. Any Python 3.12.x is acceptable, but 3.11.x is too old and 3.13.x (currently in a prerelease stage) is too new and would break some packages we will need.

Alternatively, use these links which will directly download the current version for your OS!

We assume most students are using macOS or Windows. If you are a Linux user, installation directions are largely dependent on your chosen distribution, so we cannot provide specific installation instructions, but do ask course staff if you need assistance.

Install VSCode

Next, you’ll need to install Visual Studio Code, which we will usually abbreviate as VSCode.

You’ll also need to install two VSCode Extensions

Many incorrectly assume that Jupyter is a Python specific tool. Very much not the case.

“Project Jupyter’s name is a reference to the three core programming languages supported by Jupyter, which are Julia, Python and R.”

Install Python Packages

Now for the trickiest part, installing Python packages. The trick is to be certain that they are installed within the correct Python installation, the one you just installed. To accomplish this, we’ll use a bit of Jupyter magic.1

Launch VSCode and create a new Jupyter notebook. In the top right corner, click “Select Kernel.” This will show you a list of available Python kernels. If you see the version you just installed, click that! Do this each time you create a notebook.

Next to the version numbers in this list, you’ll see the full path to the Python installation that it refers to. If that includes either conda, anaconda, or homebrew, we do not want that! Those are not what you just installed.

Now we need to install the ipykernel package. VSCode will prompt you to do so after selecting a kernel. If selecting a kernel does not trigger this prompt, add a cell to the notebook you opened, write 2 + 2 in the cell and attempt to run the cell. This should trigger the prompt.

With the ipykernel package installed, Jupyter notebooks in VSCode will be fully functional.

To ensure that you are installing additional packages into the correct installation of Python, we recommend doing so within a Jupyter notebook using magic commands. Specifically, we will use %pip to insure that packages are installed within the currently selected kernel.

Create a cell in the notebook you’re using, add the following, and run the cell.

%pip install --upgrade pip
%pip install \
    joblib \
    numpy \
    scipy \
    pandas \
    pyarrow \
    matplotlib \
    seaborn \
    scikit-learn

Be sure to use % and not !. Using % is nearly guaranteed to work, while ! makes certain assumptions about your setup that might not be true.

At this point we should pause for a bit of testing. Create another cell, add the following code, and run the cell.

# checking python
import sys
major = sys.version_info.major
minor = sys.version_info.minor
micro = sys.version_info.micro
print(f"Using version {major}.{minor}.{micro}!")
Using version 3.12.7!

If your output matches, you’re running the correct Python version.

Repeat this process for the following code to verify that packages were installed properly and within the correct Python installation.

# checking numpy
import numpy as np
np.random.seed(42)
y_true = np.random.uniform(low=0, high=10, size=25)
y_pred = np.random.uniform(low=0, high=10, size=25)
rmse = np.sqrt(np.mean((y_true - y_pred) ** 2))
print(f"The RMSE is {round(rmse, 2)}.")
The RMSE is 4.21.

If this output also matches, your Python, packages, VSCode, and Jupyter are all up and running! If you’re having issues, stop what you’re doing and ask a course staff for assistance!

It is important that you use somewhat recent versions of packages. This will be particularly important for labs. This will happen automatically if you are installing Python 3.12 for the first time this semester, which is highly likely.

If you had already installed Python 3.12 and need to update a package, use for example:

%pip install --upgrade pandas

You’ll need to do that for any of the packages listed above. As one big command, that would be:

%pip install --upgrade \
    joblib \
    numpy \
    scipy \
    pandas \
    pyarrow \
    matplotlib \
    seaborn \
    scikit-learn

Install Quarto

Use of Quarto is required to properly render lab reports in CS 307. To use Quarto together with Jupyter and VSCode, you’ll need to install Quarto, as well as a VSCode Extension.

No rush to test this part of the setup. You’ll get a chance to do so with Lab 00.

Missing macOS SSL Certificates

For whatever reason, Python on macOS does not ship with the required SSL certificates installed in order to make proper web requests over Hypertext Transfer Protocol Secure (HTTPS). Python on macOS does however ship with a script that will install them for you.

Navigate to the Applications folder then find the Python 3.12 folder. In that folder there will be a file name Install Certificates.command. Double click that file to run it. You should see a terminal window open and some code will run. When you see [Process completed], the necessary SSL certificates will be installed.

If you had encountered an error that brought you to these directions, restart VSCode after following these instructions before trying again.

Footnotes

  1. Technically the magic is from ipython.↩︎