IncrediCoders: Install Visual Studio Code, Python, and Pygame - IncrediCoders/Python1 GitHub Wiki
Getting Started
Before we get started, make sure you have permission from a parent (or teacher/trusted adult) to download applications on your computer, or better yet, ask the adult go through these instructions with you.
On this page, we have three steps:
We also have the Other Info section, which explains why we're using this software (VSC, Python, Pygame, and so on).
If you already have Visual Studio Code, Python, and/or Pygame installed, these steps might help you update your software to the current version. But if you're experiencing any issues (including complications due to previous software versions), see Updating Your Software.
1. Install Visual Studio Code
The first program you will download is Visual Studio Code (VSC). VSC is a code editor that runs on your computer. It's free and works on Windows, Mac, and Linux operating systems. VSC is where you’ll be writing and running your code, as you go through each level.
- Click here to download VSC. Choose a version, based on your operating system.
- Once VSC has downloaded, open up the downloaded file. After running through the steps of the installer, the program will launch and you should see the welcome page (as shown below).
NOTE: This image shows the folders already loaded into Visual Studio Code. After you install the software, the next step is to load the IncrediCoders files into Visual Studio Code.
2. Install Python and Python Extension in VSC
You can code in Python directly from Visual Studio Code (VSC). You will need to install both Python (which includes the Python Interpreter) and the Python Extension for VSC.
Install Python
For Windows
We'll be installing the latest version of Python, from python.org. The Windows operating system is already selected when you see the Download Python button. Follow these steps:
Notes: You will need admin access (in Windows) in order to download Python this way. If you don't have admin access, you'll need to download Python from the Microsoft Store. Make sure you download the latest version of Python (the highest number). We've experienced some issues, where the Download button doesn't always directly download the file. If you experience this, refresh the page and try again.
- In the Python Setup installer, make sure the option Add Python X to PATH is selected (where X is the version number). This is needed for Pygame to work with your code. See the checkbox at the bottom of the Python Setup image.
- Verify the Python installation by using the instructions in the Verifying Python Installation section below.
For MacOS
In order to install Python for macOS, we'll be using Homebrew.
-
Install Homebrew. Paste this script into the MacOS Terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Note: Click here for more details about installing Homebrew.
-
In the VSC Terminal prompt, use the command
brew install python3
. For help with the VSC Terminal, see Using the Terminal below.Note: For later versions of Python (such as Python 4), your brew command should specify the later version instead.
-
Verify the Python installation by following the Verifying Python Installation instructions below.
For Linux
Linux should have the latest version of Python already installed (through its manual and automatic updates). You can verify the version on your device by using the steps below. If you would like to update Python to the latest version, see Updating Your Software.
You should install Pip3, for Pygame and package installation. Run the following script in the Terminal:
sudo apt-get install pip3
NOTE: As newer versions are released, you may need to check if the command needs to be updated, such as updating "
pip3
" to "pip4
".
Using the Terminal
At the bottom of the VSC window, there should be a tab called Terminal (see the red box in the image below).
If the Terminal tab is not selected, click the tab, and a terminal should appear. If there isn't a Terminal tab at all, you can open a new Terminal window by clicking on the Terminal drop-down menu in the menu bar at the top left of VSC, and then select the New Terminal option. The Terminal should now appear at the bottom of your screen.
Verifying the Python Installation
Once Python is downloaded, go back to VSC. We want to verify that it successfully downloaded.
- For Windows/Linux type
py -0
in the Terminal window, and then press Enter. For MacOS, use the commandpython3 -V
. - Versions of Python that are downloaded on to your computer will show up on the screen. See the example image.
When you see the line that lists the version(s) of Python (such as Installed Pythons found by py Launcher...
), we know that Python is on your computer. (If you have multiple versions of Python and are experiencing setup issues, see Updating Your Software.)
Install the Python Extension in VSC
You can install extensions for different coding languages directly in VSC. The Python Extension set that we will install is created by Microsoft and is free to use. It includes a linter, debugging, IntelliSense, and other helpful features for writing code.
- Within VSC, click the Extensions tab on the far left sidebar. (It's on the bottom, and the symbol is four squares.)
- Search for "python" in the search bar. Click the first/top result (the one from Microsoft), called "Python." Verify it's the extension from Microsoft. (There are more extensions for Python, created by the community. You're welcome to explore them to see if you want any additional features.)
- Click Install.
- Alternatively, you can find the Python extension in the Visual Studio Marketplace. Click the green Install button, which will take you back into VSC, to the page for the Python extension. You'll also need to click Install on this page, inside VSC.
3. Install Pygame
NOTE: You should have already installed Python and the Python Extension for VSC. If you haven't installed the extension, then when you open Visual Studio Code, you'll be prompted to install the Python Extension and to select the Python Interpreter (which version of Python you're using).
Pygame is the last thing you need to download! It's a set of modules designed for creating videogames in Python. It's free and can be used on many different platforms and operating systems.
For Windows
In the Terminal window of VSC, enter the following command (for help with the VSC Terminal, see Using the Terminal above):
py -m pip install -U pygame --user
For MacOS and Linux
python3 -m pip install -U pygame --user
Notes: Like when we downloaded Python, you will need admin access (in your OS) to download Pygame. For later versions of Python (such as Python 4), your pip command should specify the later version instead (such as
python4
instead ofpython3
). If you're using Linux, make sure you installed Pip first (you runsudo apt-get install pip3
in the Terminal).
You can also install Pygame by downloading the package from this website (you would select the most recent version), but we don't recommend it for the newer users (it's a little complicated).
Verifying Pygame Installation
- In the VSC Terminal, enter the command
pip show pygame
(for Windows computers). - For MacOS and Linux computers, use
pip3 show pygame
. The scriptpip show pygame
also works for MacOS, but we recommend it if you have only one version of Python on your computer, or if the latest version of Python is your default.
This will display several lines of information about Pygame, like the version and the file location. When you see this, Pygame has successfully installed.
Other Info
Here is more information about setup topics:
- Checking for and Installing the Latest Versions: You might already have an older version of Visual Studio Code, Python, and/or Pygame installed on your computer. Sometimes, the instructions above will update your software (or it will be clear how to update your software). But for dedicated instructions and to troubleshoot any issues, see Updating Your Software.
- Other IDE Software: IDE means Integrated Development Environment. It's the app you use to code your programs and games. There are a lot of great ones, like Eclipse, Netbeans, Pycharm, Spyder, Atom, and so on. We chose Visual Studio Code (VSC) because it has our favorite features of Visual Studio, it's much more lightweight (loads fast), and it works on Windows, Mac, and Linux.
- Online IDEs: We experimented with a few options, and we found that Replit works best, especially because they have compatibility with the Pygame extension. If you're interested in using Replit, see Set up the Replit online editor.
- Python: We believe Python is a great first language to learn, as it is a full, professional language that we find easier to learn than other languages (due to its syntax and readability). It's very versatile, because you can use it many different fields of computer science, including data science, machine learning, web development, and game development. There are also many resources available, from its large, supportive community.
- Pygame: Sometimes you'll find Python books or instructions, but they often don't teach you how to create full games. For our book, we want the reader to be able to make a full (but simple) game, rather than a program that's just text and numbers. So, we're using Pygame!
- A Linter: A linter is a tool that looks for programming errors, syntax errors, and other problems with your code. A common one used for Python is Pylint. Visual Studio Code already has a linter built-in (in the Python Extensions) with some basic features.
- Pip: Pip is installed with the Python Interpreter, as part of the Python package. It is a tool that manages Python packages, like Pygame. Although there are multiple versions of Pip (such as version 2 and version 3), we don't have to specify the Pip version.
- PyInstaller: This allows you to run an executable of the Python programs and games you're making with IncrediCoders. This way, you see what they look like, before you build them! PyInstaller requires you to download a large folder (and large file size), but it's still the best solution we've found for this. However, we're always looking for more ideas. You can download and run the complete programs and games. The links are available on each Level's Help page (such as Level 1: Help).
Next Steps
If you are experiencing setup issues, it might be due to existing software on your computer. See Updating Your Software.
Next, you're going to download all the code files and images that you're going to use to create your programs and games! It's all free and available on GitHub.
Click here to load the IncrediCoders files into Visual Studio Code.
If you have any questions, ideas, or issues with this level, then please let us know by creating a GitHub Issue.
Otherwise, head to the main resources page for this book.