For this course, you’ll be using the latest stable version of Python available, which is currently Python 3.9.
We’ll be using VS Code throughout the class to provide a consistent experience for all students. Once the course is over, feel free to go back to the editor of your choice to continue on your Python adventure.
If you’re used to keybindings in a different editor, you can set up a keymaps extension in VS Code to match what you’re used to.
Download Python3 Download Visual Studio Code Python Extension for Visual Studio Code
To make sure you have all the prerequisites properly installed:
Type the following on your terminal.
$ python3 --version
You should see something like
Python 3.9.0
If you don’t see a Python version greater than 3.9, please follow the instructions for installing Python3 again.
A Virtual Environments in Python is a self-contained directory that contains a Python installation for a particular version of Python.
It’s a very useful way to make sure that we’re using the right Python version when we’re working on a particular project.
Let’s create a project directory and a Python 3.9 Virtual Environment.
Open a terminal window. Type the following.
(Do not type the $
character, that signifies a prompt.)
$ cd ~
$ mkdir pyworkshop
$ cd pyworkshop
$ python3 -m venv env
$ source env/bin/activate
source env/bin/activate
is how you activate your virtual environment on Mac or Linux. You’ll want to do that each time you enter this Python project directory from a new shell.
Your prompt should look like this to indicate that the virtual environment is active.
(env) $
Upgrade pip, the Python package installer to the latest version.
(env) $ python3 -m pip install --upgrade pip
You are expected to work from this project folder for the duration of the class, with an activated virtual environment.
If something is not working, please make sure that you’re in the correct project directory with an activated virtual environment.
Look for VS Code in your Applications, or type the following in your terminal.
$ code --version
You should see something like:
1.49.0
e790b931385d72cf5669fcefc51cdf65990efa5d
x64
code
on your PathIf typing code
in your terminal doesn’t work, you may need to follow the instructions to install it on your path, here.
If you don’t see VS Code, please follow the instructions for installing VS Code again.