How to Use Python on Windows
After successfully installing Python on Windows using any of the supported methods, you can start executing Python commands and scripts. Python can be run through Windows PowerShell, Command Prompt, or an IDE such as IDLE or VSCode. Follow the steps below to use Python effectively on Windows.
Run Python in PowerShell
Open the Windows PowerShell to verify that Python is correctly installed.
Step 1: Check Active Python Version
> python --version
Step 2: Open the Python Shell
> python
Step 3: Run a Simple Python Command
Print a message using Python:
>>> print("Greetings from centron")
Expected Output:
Greetings from centron
Step 4: Exit the Python Shell
>>> exit()
Step 5: Create and Run a Python Script
Create a simple script named hello.py and execute it:
> "print('Greetings from centron!')" > hello.py
> python hello.py
Use IDLE to Run Python Code
Python includes IDLE, a built-in GUI-based development environment for writing and testing Python code. Follow the steps below to run Python scripts using IDLE.
- Open the Windows Start menu, search for IDLE, and open it.
- Verify that the Python shell appears, then run the following command:
>>> print("Greetings from centron")
Expected Output:
Greetings from centron
To create and execute scripts in IDLE:
- Click File → New File to open a new editor window.
- Write your Python code.
- Press Ctrl + S to save it with a
.pyextension. - Press F5 to execute the file.
Create and Manage Virtual Environments
Python virtual environments help isolate dependencies for each project, avoiding conflicts between packages. Follow the steps below to install and use virtual environments in Windows.
Step 1: Check the Default Python Version
> python --version
Expected Output:
Python 3.13.3
Step 2: Install the virtualenv Module
> python -m pip install virtualenv
To install it for a specific version, such as Python 3.12:
> python3.12 -m pip install virtualenv
Step 3: Create a Virtual Environment
Create a new virtual environment named venv:
> python -m virtualenv venv
Step 4: Activate the Virtual Environment
> venv\Scripts\activate
Your terminal should now display the virtual environment name in parentheses:
(venv) PS C:\path\to\your\project>
Step 5: Install Packages with Pip
Use Pip to install a package such as requests:
> pip install requests
Step 6: List Installed Packages
> pip list
Expected Output:
Package Version
------------------ ---------
certifi 2025.1.31
charset-normalizer 3.4.1
idna 3.10
pip 25.0.1
requests 2.32.3
urllib3 2.3.0
Step 7: Deactivate the Virtual Environment
> deactivate
Upgrade Pip on Windows
Pip, Python’s package manager, is usually included with Python installations. However, if you’re managing multiple Python versions, it may require manual upgrades. Follow the steps below to verify and upgrade Pip.
Step 1: Check Pip Version
> pip --version
Expected Output:
pip 24.3.1 from C:\Python313\Lib\site-packages\pip (python 3.13)
Step 2: Upgrade Pip
> python -m pip install --upgrade pip
Step 3: Verify the Upgrade
> pip --version
Expected Output:
pip 25.0.1 from C:\Python313\Lib\site-packages\pip (python 3.13)
Conclusion
You have installed Python and Pip on Windows using both terminal and GUI methods. You can now use Python to create virtual environments, develop applications, and run scripts through IDEs or PowerShell. For more details and advanced configuration options, visit the official Python documentation.


