Python Installation
1. What is Python?
Python is a high-level programming language used for:
- Web development
- Data analysis
- Artificial Intelligence and Machine Learning
- Automation
- Cybersecurity
- IoT
- Desktop applications
- Scripting
- Education and programming practice
Before writing Python programs, we need to install the Python interpreter.
2. What is the Python Interpreter?
When you write:
print("Hello World")
your computer does not directly understand Python code. The Python interpreter reads your Python code and executes it.
So: Python code → Python interpreter → Computer executes the program
3. Download Python
For Windows, download Python from the official Python website: Python Official Website
Go to: Downloads → Windows Then download the latest stable Python 3 release. For most modern Windows computers, choose: Windows installer (64-bit)
4. Start the Installation
After downloading the .exe installer, open it.
You will see the Python installation window.
The most important option is:
Add python.exe to PATH
Make sure this checkbox is selected:
☑ Add python.exe to PATH
Then click: Install Now This is especially important for beginners.
5. What is PATH?
PATH is a Windows environment variable that tells the operating system where executable programs are located.
For example, when you type:
python
Windows searches the directories listed in PATH. If Python's installation directory is in PATH, Windows can find Python automatically. Without PATH, you might get an error such as:
'python' is not recognized as an internal or external command
6. Python Installation Location
Python is commonly installed somewhere similar to:
C:\Users\YourName\AppData\Local\Programs\Python\Python3xx\
The exact location depends on the Python version and installation method. You don't normally need to change the installation location for a beginner installation.
7. Verify Python Installation
After installation, open: Command Prompt
Press:
Win + R
Type:
cmd
Press Enter.
Then run:
python --version
You should see something similar to:
Python 3.x.x
You can also use:
python -V
8. Check the Python Executable
Run:
where python
This shows where Windows is finding Python. Example:
C:\Users\YourName\AppData\Local\Programs\Python\Python314\python.exe
You can also run:
where py
9. The py Command
Windows Python installations often provide the Python Launcher. You can run:
py --version
For example:
Python 3.14.6
You can run a Python program with:
py program.py
instead of:
python program.py
Both can be useful.
10. Open the Python Interactive Shell
Type:
python
You may see:
Python 3.x.x >>>
The >>> means Python is waiting for your command.
Try:
print("Hello World")
Output:
Hello World
To exit:
exit()
Or press:
Ctrl + Z
then Enter on Windows.
11. What is pip?
pip is Python's package installer.
Python itself provides many built-in features, but external libraries can be installed using pip.
For example:
pip install requests
This installs the requests library.
Check pip:
pip --version
You can also use:
python -m pip --version
The second form is often more reliable because it explicitly uses the pip associated with that Python installation.
12. Install a Python Package
For example:
python -m pip install requests
Then test it:
import requests print(requests.__version__)
13. Upgrade pip
You can update pip with:
python -m pip install --upgrade pip
Then verify:
python -m pip --version
14. Where Are Python Packages Installed?
When you install a package, pip puts it into the appropriate Python environment. You can see installed packages with:
pip list
Example:
Package Version ---------- ------- pip 26.x requests 2.x
You can also use:
python -m pip list
15. Install VS Code
Python can be written in Notepad, but for programming, Visual Studio Code is much better. Visual Studio Code
Install VS Code normally. Then open VS Code.
16. Install the Python Extension
Inside VS Code:
- Open Extensions
- Search for:
Python - Install the official Python extension from Microsoft This gives you features such as:
- Code completion
- Error detection
- Debugging
- Python interpreter selection
- Running Python files
- IntelliSense
17. Create Your First Python Program
Create a folder:
PythonProjects
Open that folder in VS Code. Create:
hello.py
Write:
print("Hello World")
Save it.
18. Run the Python Program
You can run it from the VS Code terminal:
python hello.py
or:
py hello.py
Output:
Hello World
You can also use the Run Python File button in VS Code.
19. Select the Python Interpreter in VS Code
Press:
Ctrl + Shift + P
Search:
Python: Select Interpreter
Select your installed Python version. For example:
Python 3.14.x
If you later create a virtual environment, you can select that environment here too.
20. What is a Virtual Environment?
A virtual environment is an isolated Python environment for a project. Suppose you have:
Project A
which needs:
requests 2.x
and another project:
Project B
which requires a different package version. Installing everything globally can cause conflicts. A virtual environment keeps each project's packages separate.
21. Create a Virtual Environment
Inside your project folder:
python -m venv .venv
This creates:
project/ │ ├── .venv/ └── hello.py
22. Activate the Virtual Environment
On Windows Command Prompt:
.venv\Scripts\activate
You should see something like:
(.venv) C:\Users\YourName\project>
The (.venv) means the environment is active.
23. Install Packages Inside the Environment
Now:
python -m pip install requests
The package is installed into that project's virtual environment.
24. Deactivate the Environment
When finished:
deactivate
The (.venv) disappears.
25. Recommended Project Structure
A basic Python project can look like:
myproject/ │ ├── .venv/ ├── main.py ├── requirements.txt └── README.md
You normally do not upload .venv to GitHub.
Add this to .gitignore:
.venv/
26. Save Installed Packages
If your project uses several packages:
python -m pip freeze > requirements.txt
This creates:
requirements.txt
Another computer can install them with:
python -m pip install -r requirements.txt
27. Python Installation Verification Checklist
After installing Python, check these commands:
python --version
py --version
python -m pip --version
where python
where py
If these work, your Python installation is generally ready.
28. Common Problem: python Not Recognized
If you get:
'python' is not recognized...
First try:
py --version
If py works but python doesn't, Python may be installed but python.exe isn't available through PATH.
You can also check:
where py
Then review your PATH settings.
29. Windows App Execution Alias Problem
Sometimes Windows has aliases for:
python.exe python3.exe
which can interfere with the real Python installation. Go to:
Settings → Apps → Advanced app settings → App execution aliases
Look for:
python.exe python3.exe
If they are redirecting python to the Microsoft Store instead of your installed Python, disable the problematic aliases.
Then reopen Command Prompt.
30. Common Problem: pip Not Recognized
If:
pip
doesn't work, try:
python -m pip
For example:
python -m pip install requests
This is a good habit because it makes clear which Python installation is being used.
31. Multiple Python Versions
You may have more than one Python version installed. Check:
py -0p
This can show installed Python versions and their locations. You can then use a specific version through the Python launcher when supported, for example:
py -3.13
32. Python vs pip
Remember:
| Command | Purpose |
|---|---|
python | Runs Python |
py | Python Launcher on Windows |
pip | Installs Python packages |
python -m pip | Runs pip using a specific Python interpreter |
python file.py | Runs a Python program |
python -m venv .venv | Creates a virtual environment |
33. Python Installation Flow
The complete process is:
Download Python ↓ Run Installer ↓ Add Python to PATH ↓ Install Python ↓ Open Command Prompt ↓ python --version ↓ python -m pip --version ↓ Install VS Code ↓ Install Python Extension ↓ Select Interpreter ↓ Create Project ↓ Create .venv ↓ Write Python Code ↓ Run Program
34. Recommended Setup for Beginners
For a student learning Python, I recommend this setup:
Windows │ ├── Python 3 │ ├── pip │ ├── VS Code │ └── Python Extension │ └── Project ├── .venv ├── main.py ├── requirements.txt └── README.md
Essential commands to remember
python --version
python -m pip --version
python -m pip install package_name
python -m venv .venv
.venv\Scripts\activate
deactivate
python main.py
This is the basic Python installation and setup workflow you can teach to beginners as well.