Try   HackMD

CS111 Python and VSCode Setup Guide

Setting up VSCode

Downloading Python

This course will be using Python version 3.7. If you think that you already have Python installed on your computer, you can check which version you have installed by running python3 --version in your terminal (macOS)/command prompt (Windows).

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Above: You should get a similar output to this if you don't have Python version 3.x.x installed

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Above: If you get an output similar to this (any 3.7.x), you're good to go and can skip to downloading extensions!

If you don't have Python installed or don't have Python 3.7, we would recommend downloading from this page, as it includes a 3.7 version that includes includes installers for both Windows and Mac.

If your program is currently trying to use a version that is not 3.7, you can set your VSCode to use the correct version of Python by changing the interpreter. You can press Ctrl+Shift+P on Windows or Cmd+Shift+P on Mac to open up the VSCode Command Palette. Once the search bar is open, search for and select Python: Select Interpreter. If your VSCode is able to find the Python versions you installed, you should be able to select a 3.7 version if you have it installed. You can then select the version you want.

You may be able to complete the course with the version you have installed. For instance, Python 3.9 likely won't cause any problems with the grading on our end. However, we cannot guarantee that your Python version will work all the time with Gradescope, especially if you attempt to use syntax/features that were not in 3.7. Generally, you should be fine if you are using a Python version that is 3.7 or above, and even some versions that are a few below. However, Python 2 will not work!

Download Extensions

In addition to downloading the software, you'll need to download some extensions on VSCode before you can begin coding.

  1. Open VSCode
  2. Go to the “Extensions” tab (located on the lefthand side of the IDE, the bottom icon).
  3. Search “Python” in the 'Search Extensions in MarketPlace'.
  4. Select the option that includes the word “Pylance” in the description, and install it (second extension in the screenshot below).
  5. Downloading this extension should automatically download the Jupyter extension as well (first extension in the screenshot below). Check that Jupyter is listed in your installed extensions.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Install Pytest

Please see our Python Testing Design and Clarity Guide for directions on setting up Pytest.

Once you have these extensions installed, you should be all set to code in VSCode! When writing in Python, remember to have your file end in .py (example.py).

Install Pandas

To install Pandas (a Python library for data manipulation and analysis), simply type the following into the terminal:
pip install pandas

From there, write import pandas as pd inside your Python files to use Pandas! The documentation for Pandas can be found here!

Note: pip should be installed on your computer if you downloaded Python from python.org. If you do not have pip installed please check out this guide to install it. In any case, please come to hours if you have any questions!