Install Python and Set Up VS Code with an AI Assistant - Python with AI tutorial chapter 2
Python

Install Python and Set Up VS Code with an AI Assistant

Python with AI Tutorial · Chapter 2 of 48

To install Python you download the official installer from python.org, tick one checkbox so the python command works everywhere, and then add Visual Studio Code with the Python extension as your editor. This chapter walks through both steps on Windows and Mac, runs your first script, and sets up an AI assistant next to your code.

Step 1: Download Python from python.org

Go to python.org/downloads and click the big yellow button. It always offers the latest stable release (3.12 or newer), which is what this course uses. Skip the Microsoft Store and Homebrew versions for now.

Step 2: Install on Windows

Run the downloaded .exe. Before clicking anything else, tick Add python.exe to PATH at the bottom of the first screen. This is the single most important click of the whole chapter: without it, Windows will not know where Python lives. Then choose Install Now. When the installer finishes, open a new Command Prompt or PowerShell window and type the command below.

python --version
Output:
Python 3.12.6

If you see Python was not found, PATH was not set; see the troubleshooting box below.

Step 3: Install on Mac

Open the downloaded .pkg and click through the installer. macOS ships with an old system Python that you should ignore, so on a Mac the command is python3, not python. Open Terminal and verify.

python3 --version
Output:
Python 3.12.6
Tip: Throughout the course we write python. On a Mac, read that as python3, and use pip3 where we write pip. Once VS Code is set up you rarely type either, because the Run button handles it.

Step 4: Try the interactive shell

Python comes with a REPL (read, evaluate, print, loop) where each line runs as you press Enter. Type python in your terminal, then try a calculation.

>>> unit_price = 49.99
>>> quantity = 12
>>> unit_price * quantity
599.88
>>> exit()
Output:
599.88

The >>> prompt means Python is waiting for you. exit() returns you to the normal terminal.

Step 5: Install Visual Studio Code

The REPL is fine for one-liners, but real work happens in files. Download VS Code from code.visualstudio.com (free, Windows and Mac). After installing, open the Extensions panel (the four-squares icon on the left, or Ctrl+Shift+X) and install the extension called Python by Microsoft. It brings syntax colouring, error underlining, a Run button and the interpreter picker.

Next, create a folder for the course, for example Documents\python-course, and open it in VS Code with File > Open Folder. Press Ctrl+Shift+P, type Python: Select Interpreter and pick the 3.12 entry you just installed.

Step 6: Run your first script

Create a new file named hello.py (the .py extension tells VS Code it is Python). Type this program, which prints a small invoice summary.

customer = "Northwind Traders"
items = 3
total = 1450.50

print("Invoice for", customer)
print("Items:", items)
print("Total due: $" + str(total))

Save with Ctrl+S and click the triangle Run button in the top-right corner, or right-click and choose Run Python File in Terminal. A terminal panel opens at the bottom with the result.

Output:
Invoice for Northwind Traders
Items: 3
Total due: $1450.5

You can also run any file from the terminal yourself: python hello.py. If it works, Python and VS Code are talking to each other and the setup is complete.

Step 7: Install a package with pip

Python ships with pip, its package installer. You will use it later for pandas, requests and openpyxl. Test it now with a tiny package that adds colour to terminal output.

pip install colorama
Output:
Successfully installed colorama-0.4.6

Then use it in a script to see that installed packages are available to your code.

from colorama import Fore, Style
print(Fore.GREEN + "Setup complete" + Style.RESET_ALL)
print("Ready for chapter 3")
Output:
Setup complete
Ready for chapter 3

The first line appears in green in your terminal. If pip is not recognised, use python -m pip install colorama, which always works when python does.

Step 8: Put an AI assistant beside your code

You have two good options, and many learners use both.

Option How to set it up Best for
GitHub Copilot (inside VS Code) Install the GitHub Copilot extension, sign in with a free GitHub account. The free tier gives a monthly allowance of completions and chats. Autocomplete as you type, inline explanations, fixing the file you are looking at
AI chat in a browser (ChatGPT, Claude, Copilot web) Open the chat in a browser window and snap it to the right half of the screen with Win+Right (Mac: use Split View). VS Code takes the left half. Longer explanations, pasting error messages, asking "why" questions

Whichever you choose, the habit is the same: type the example yourself, run it, and only then ask the assistant to explain or improve it.

Try it with AI

If python --version fails after installing, give your assistant the exact facts and let it diagnose the PATH problem.

I installed Python 3.12 on Windows 11 from python.org but when I type "python --version" in a new PowerShell window I get "Python was not found; run without arguments to install from the Microsoft Store". Explain what PATH is in two sentences, then give me step-by-step instructions to fix this without reinstalling, including how to find where python.exe was installed and how to add that folder to PATH. Finally tell me how to confirm the fix worked.
Try it with AI

Ask the assistant to check your VS Code setup by describing exactly what you see.

I opened hello.py in VS Code and clicked the Run button. The terminal shows the command but then prints an error (I will paste it below). My Python interpreter shown in the bottom-right status bar is "3.12.6 64-bit". Explain what the error means, whether it is a VS Code setting or a Python problem, and give the fix. Error: [paste your error here]

Common mistakes

  • Forgetting to tick Add python.exe to PATH on Windows. Rerun the installer, choose Modify, and tick it.
  • Typing python on a Mac and getting the ancient system version or nothing at all. Use python3.
  • Checking the version in a terminal that was open before the install. PATH changes only apply to new windows.
  • Saving the file as hello.py.txt. Turn on file extensions in Explorer, or create files from inside VS Code.
  • Selecting the wrong interpreter in VS Code, so a package you installed with pip is "not found". Run Python: Select Interpreter again.

Exercise

Create a file quote.py that stores a product name, a price and a quantity, then prints the line total. Run it with the VS Code Run button and again from the terminal with python quote.py. Use product "Laptop stand", price 39.5 and quantity 4.

Show answer
product = "Laptop stand"
price = 39.5
quantity = 4
print(product, "x", quantity, "=", price * quantity)
Output:
Laptop stand x 4 = 158.0

Related chapters

FAQ

Which Python version should I install in 2026?

Install the latest stable 3.x release from python.org, currently 3.12 or 3.13. Every example in this course runs on 3.12 and newer. Never install Python 2.

Do I need VS Code, or can I use IDLE or Jupyter?

IDLE ships with Python and works for tiny scripts, and Jupyter is great for data analysis later. VS Code is recommended because it runs files, manages packages and hosts GitHub Copilot in one window.

Is GitHub Copilot free?

GitHub offers a free Copilot tier with a monthly limit on completions and chat messages, which is plenty for this course. Students and teachers can get the full version free through GitHub Education.

Working with spreadsheets too? Ready-made Excel, Google Sheets and Power BI templates are at NextGenTemplates.com.

Chapter 2 of 48 · Python with AI: all 48 chapters

PK
Meet PK, the founder of NeotechNavigators.com! With over 15 years of experience in Data Visualization, Excel Automation, and dashboard creation. PK is a Microsoft Certified Professional who has a passion for all things in Excel. PK loves to explore new and innovative ways to use Excel and is always eager to share his knowledge with others. With an eye for detail and a commitment to excellence, PK has become a go-to expert in the world of Excel. Whether you're looking to create stunning visualizations or streamline your workflow with automation, PK has the skills and expertise to help you succeed. Join the many satisfied clients who have benefited from PK's services and see how he can take your data analysis skills to the next level!
https://neotechnavigators.com