Before you write your first Python program, you need two things on your computer: Python and a code editor. Python runs your code. The code editor is the place where you write it. In this guide, we will install both on Windows, one small step at a time. It takes about 10 to 15 minutes.
- How to download and install Python on Windows
- How to install VS Code and the Python extension
- How to write and run your first Python program
- How to fix the most common errors
What You Need
- A Windows 10 or Windows 11 computer
- An internet connection
- About 1 GB of free space
Step 1: Download Python
- Open your browser and go to python.org.
- Click on Downloads in the top menu.
- Click the big yellow button that says Download Python 3.x.x. The numbers can be different, because the website always shows the latest version.
- Wait for the file to finish downloading. It is usually saved in your Downloads folder.
Step 2: Install Python (Very Important Step)
- Open your Downloads folder and double-click the Python file you just downloaded.
- A setup window will open. Before you click anything, look at the bottom of the window.
- Tick the box that says "Add python.exe to PATH". This is the most important step. If you forget it, Python will not work in the terminal.
- Now click Install Now.
- If Windows asks "Do you want to allow this app to make changes?", click Yes.
- Wait for the installation. When you see "Setup was successful", click Close.
What is PATH? PATH is a list of places where Windows looks for programs. When you add Python to PATH, Windows can find Python when you type the word python.
Step 3: Check That Python Is Installed
- Press the Windows key on your keyboard.
- Type cmd and press Enter. A black window (Command Prompt) will open.
- Type this and press Enter:
python --version
If you see something like Python 3.13.0, Python is installed correctly. Your number can be different, and that is fine.
If you see an error instead, do not worry. Scroll down to the section "Common Errors and How to Fix Them".
Step 4: Download and Install VS Code
VS Code (Visual Studio Code) is a free code editor made by Microsoft. It colors your code, finds mistakes, and makes writing code easier than Notepad.
- Go to code.visualstudio.com.
- Click Download for Windows.
- Open the downloaded file from your Downloads folder.
- Select "I accept the agreement" and click Next.
- Keep clicking Next until you see the "Select Additional Tasks" page. Tick these three boxes: Add "Open with Code" action to Windows Explorer file context menu, Add "Open with Code" action to Windows Explorer directory context menu, and Add to PATH (it is usually ticked already).
- Click Next, then Install.
- When it finishes, click Finish. VS Code will open.
Step 5: Install the Python Extension in VS Code
An extension is a small add-on. The Python extension helps VS Code understand Python code.
- In VS Code, click the Extensions icon on the left side. It looks like four small squares. You can also press
Ctrl + Shift + X. - In the search box, type Python.
- Choose the first result made by Microsoft.
- Click the blue Install button.
Step 6: Create a Folder and Your First Python File
It is good to keep all your practice files in one folder. Follow these steps:
- On your Desktop, right-click and choose New > Folder. Name it python-practice.
- In VS Code, click File > Open Folder. Select the python-practice folder and click Select Folder.
- If VS Code asks "Do you trust the authors of the files in this folder?", click Yes, I trust the authors.
- In the left panel, click the New File icon and name the file
hello.py. The.pyat the end is very important. It tells the computer that this is a Python file. - Type the code below in the file, then press
Ctrl + Sto save it.
print("Hello, world!")
Step 7: Run Your First Program
There are two easy ways to run your code.
Method 1: Use the Run button. Look at the top right corner of VS Code. Click the small triangle (Play) button. A terminal will open at the bottom and show your result.
Method 2: Use the terminal. In VS Code, click Terminal > New Terminal in the top menu. Then type this and press Enter:
python hello.py
You should see this output:
Hello, world!
Congratulations! You have installed Python and VS Code, and you have run your first program.
Common Errors and How to Fix Them
Error 1: 'python' is not recognized as an internal or external command
This means Python was installed without PATH. To fix it:
- Search "Python" in the Start menu and open the installer again.
- Click Uninstall to remove Python.
- Install it again, and this time tick "Add python.exe to PATH".
- Close all terminal windows, open a new one, and try again.
You can also try py --version. On Windows, py often works even when python does not.
Error 2: Microsoft Store opens when I type python
Windows has a shortcut that opens the Store. To turn it off:
- Press the Windows key and type Manage app execution aliases. Open it.
- Turn OFF the two items named python.exe and python3.exe (App Installer).
- Open a new terminal and try again.
Error 3: The Run (Play) button is not showing
Check these things:
- Check that your file name ends with
.py. - Check that the Python extension is installed (Step 5).
- Restart VS Code.
Error 4: VS Code cannot find Python
To fix it:
- Press
Ctrl + Shift + P. - Type Python: Select Interpreter and press Enter.
- Choose the Python version from the list.
Common Mistakes Beginners Make
- Forgetting to tick "Add python.exe to PATH". This is the number one mistake.
- Forgetting to save the file. Press
Ctrl + Sbefore you run the code. - Saving the file as hello.py.txt. Make sure the file ends with only
.py. - Typing the code with wrong quotes. Use simple straight quotes like
"Hello". - Not using a folder. Keep all your practice files in one folder so you can find them easily.
What to Learn Next
Now your setup is ready. The next step is to learn variables and data types. Variables are like boxes where you store numbers and text. Read my post Python Variables and Data Types Explained with Examples to learn them with simple examples. If you missed the full learning plan, read my Python roadmap for beginners first.
Frequently Asked Questions (FAQs)
Is Python free to download?
Yes. Python and VS Code are both free. Download them only from python.org and code.visualstudio.com.
Why do I need to tick "Add python.exe to PATH"?
It lets Windows find Python when you type python in the terminal. Without it, you will see the "not recognized" error.
Can I use another editor instead of VS Code?
Yes. You can use PyCharm, IDLE or any other editor. I suggest VS Code because it is free, light and easy for beginners.
Do I need internet to write Python code?
You need internet only to download Python and VS Code. After that, you can write and run code without internet.
Final Thoughts
Setting up your tools is the hardest part for many beginners, and you have just finished it. If you get any error, read the message slowly and check the fixes above. Most problems are small, and almost all of them are solved by the PATH step. Keep practicing a little every day, and write your own print() lines in hello.py to get comfortable.










Comments
Post a Comment