Beginner Chapter 4 · 20 min read · Module 1: Python Fundamentals
Installing Python on Windows
- After this chapter you can download the correct Python installer for Windows from python.org.
- You can explain why the Add python.exe to PATH option matters and where to find it in the installer.
- You can check an installation with py --version and python --version.
- You can open Python in interactive mode and run a script file from Command Prompt.
- You can solve common Windows problems such as the Microsoft Store shortcut and a missing PATH entry.
Before you can write Python programs on your own computer, you need to install Python. On Windows this is simple, but a few small choices in the installer decide whether everything works smoothly later. Many beginners skip one tick box and then spend an hour wondering why the command prompt does not know the word python.
In this chapter you will follow the full path: getting the installer from the official website, choosing the right options, running it, and testing the result. You will also meet the py launcher, a small helper program that comes with Python on Windows and makes it easy to start the right version.
We will also look at the folders that Python uses, how Windows paths are written, and what to do when something goes wrong. The code examples in this chapter use small programs that check your setup, so you can run them as soon as the installation is finished.
Before you start
Python for Windows is free. You do not need to pay, create an account or install anything else first. You only need a computer running a supported version of Windows, some free disk space (a few hundred megabytes is enough), and an internet connection to download the installer. Recent Python versions need Windows 10 or newer, so check that your system is up to date if the installer refuses to start.
Always download Python from the official website, python.org. Other sites may offer files that look the same but contain unwanted software. On the Downloads page, the site detects that you are on Windows and shows a big button for the latest stable release. Click it, and your browser will save a file with a name like python-3.13.0-amd64.exe. The amd64 part means the 64-bit version, which is the right choice for almost every modern computer.
Running the installer
Double-click the downloaded file. The first screen is the most important one. It shows two big choices, Install Now and Customize installation, and at the bottom two tick boxes. Look carefully at the box named Add python.exe to PATH and tick it. If you forget this, you can still fix it later, but it is much easier to tick it now.
The other tick box, Use admin privileges when installing py.exe, only matters if you want the launcher for all users on the computer. A normal learner can leave it as it is. After that, press Install Now. Windows may ask you to confirm with a security question; answer yes. The installer then copies files for a minute or two and shows a Setup was successful screen. Some versions also offer a button called Disable path length limit. It is safe to click, and it avoids rare errors with very long folder names.
What does PATH mean?
When you type a word like python in Command Prompt, Windows looks for a program with that name. It does not search the whole disk. It only looks in a list of folders called the PATH. If the folder that contains python.exe is on this list, the command works from anywhere. If it is not on the list, Windows says that the command is not recognized.
| Option in installer | What it does | Should a beginner use it? |
|---|---|---|
| Install Now | Installs for your user with default settings | Yes |
| Customize installation | Lets you pick features and the folder | Only if you need a special folder |
| Add python.exe to PATH | Lets you type python anywhere | Yes, always tick it |
| Disable path length limit | Removes the 260 character limit on paths | Yes, it is safe |
Checking the installation
Open the Start menu, type cmd and press Enter to open Command Prompt. Type python --version and press Enter. You should see the version number you installed. On Windows you can also use the py launcher: the command py --version works even when PATH is not set, because the launcher is installed in a folder that Windows already knows. The launcher is also helpful when you have several Python versions, because py -3.12 starts that exact version.
C:\Users\Asha> python --version
Python 3.13.0
C:\Users\Asha> py --version
Python 3.13.0
C:\Users\Asha> py -0
-V:3.13 * Python 3.13 (64-bit)The output above is only an illustration, because your version number will be different. The command py -0 lists all versions that the launcher can find, and the star marks the default one. If py --version works but python --version does not, then PATH is the problem, not the installation.
Your first run
Type python alone and press Enter. You will see the interactive prompt >>>, where each line you type is run at once. To leave, type exit() and press Enter. For real programs, save your code in a file ending in .py, then run it with python hello.py. Command Prompt must be in the folder that contains the file, so use the cd command to move there first.
The next program is a good test after any installation. It checks that your Python is version 3.10 or newer, which is what this course expects. You can save it as check.py and run it, or paste it into the interactive prompt.
import sys
version = sys.version_info
print("Major version:", version.major)
print("Is 3.10 or newer:", version >= (3, 10))Understanding Windows paths
Windows writes folder paths with a backslash, such as C:\Users\Asha\project. In Python strings the backslash is a special character, so "\n" means a new line and "\t" means a tab. This causes confusing bugs when you write a Windows path by hand. The cure is to use a raw string by putting an r before the quote, or to use the os.path and pathlib tools that build paths for you.
The module ntpath is the Windows version of os.path. It behaves the same on every computer, so we can use it to practise Windows paths even if we are not on Windows right now.
import ntpath
folder = ntpath.join("C:\\", "Users", "Asha", "projects")
file_path = ntpath.join(folder, "hello.py")
print(file_path)
print(ntpath.basename(file_path))
print(ntpath.splitext(file_path)[1])
print(ntpath.splitdrive(file_path)[0])Where does Python live?
By default, Install Now places Python in a folder inside your user profile, for example C:\Users\Asha\AppData\Local\Programs\Python\Python313. This folder holds python.exe, the standard library and a Scripts folder where tools such as pip are kept. The installer adds both the main folder and the Scripts folder to PATH when you tick the box. Because this location is inside your own profile, you do not need administrator rights to install.
Fixing common problems
- python is not recognized: PATH was not set. Run the installer again, choose Modify, and tick the PATH option, or use the
pylauncher instead. - The Microsoft Store opens when you type python: Windows has a shortcut that points to the Store. Turn it off under Settings, Apps, Advanced app settings, App execution aliases, and switch off the python entries.
- The wrong version starts: more than one Python is installed. Use
py -3.13to pick the one you want, or remove the old version. - The installer fails with a security message: download the file again from python.org, and check that your antivirus is not blocking it.
Python syntax
python --versionpy -3.13 script.pypython script.pyr"C:\Users\Asha\notes.txt"Real-world applications
- Setting up a personal computer for learning and building Python programs.
- Preparing a school or office laptop so that scripts for automation can be run from Command Prompt.
- Installing several Python versions side by side to test a project on each of them.
- Getting a working base for tools such as pip, virtual environments and code editors.
Common mistakes
Fix: Run the installer again, choose Modify or Repair, and tick the box. You can also add the folders to PATH by hand in System Settings.
Fix: Always use python.org or the Microsoft Store listing published by the Python Software Foundation.
Fix: Close the window and open a fresh one so it reads the new PATH.
Fix: Use a raw string r"C:\new\test.txt" or double the backslashes, because \n is a new line.
Fix: The >>> prompt already runs Python. Leave it with exit() before running shell commands such as python script.py.
Important tips
- Choose Install Now for the simplest setup and tick the PATH box.
- Use py -0 to see which versions are installed.
- Create a folder such as C:\Users\YourName\python-practice for all your course files.
- Install only one Python version while you are learning, to avoid confusion.
Key points summary
- Download Python only from python.org.
- Tick Add python.exe to PATH on the first installer screen.
- python --version and py --version confirm that the install works.
- The py launcher can choose between several Python versions.
- Windows paths use backslashes, so use raw strings in Python code.
- Open a new Command Prompt after any PATH change.
Exam and interview points
- The official download site is python.org.
- The PATH option allows the command python to run from any folder.
- py is the Python launcher for Windows and can select a version with flags such as -3.12.
- exit() or Ctrl+Z then Enter leaves the interactive prompt on Windows.
- In Python strings, the backslash starts an escape sequence, so Windows paths need raw strings.
Quick revision
- Download from python.org, run the .exe file.
- Tick Add python.exe to PATH, then Install Now.
- Test with python --version or py --version.
- python alone opens the >>> prompt; exit() closes it.
- Run a file with python filename.py.
- Use r"..." for Windows paths in code.
Frequently asked questions
Do I need administrator rights to install Python?
No. The default Install Now option installs into your own user folder, so normal users can do it. Admin rights are only needed if you choose to install for all users.
Should I pick the 32-bit or the 64-bit installer?
Pick 64-bit unless your computer is very old. The download button on python.org already picks the best one for your system in most cases.
What is the difference between python and py?
python runs whichever Python is first on PATH. py is the launcher that finds installed versions by itself and lets you choose one, for example py -3.12.
Can I install a new version over an old one?
Yes. Minor updates, such as 3.13.0 to 3.13.1, replace the older one. A new feature release, such as 3.12 to 3.13, installs next to the old one, and both can live together.
How do I remove Python?
Open Settings, Apps, find Python in the list and choose Uninstall. Your own .py files are not touched.
Practise this chapter
16 practice questions Take the chapter quiz