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

Step 2: Open the Python Shell

Step 3: Run a Simple Python Command

Print a message using Python:

>>> print("Greetings from centron")

Expected Output:

Step 4: Exit the Python Shell

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.

  1. Open the Windows Start menu, search for IDLE, and open it.
  2. Verify that the Python shell appears, then run the following command:

>>> print("Greetings from centron")

Expected Output:

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 .py extension.
  • 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

Expected Output:

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

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:

Step 6: List Installed Packages

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

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

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

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.

Source: vultr.com

Create a Free Account

Register now and get access to our Cloud Services.

Posts you might be interested in:

Moderne Hosting Services mit Cloud Server, Managed Server und skalierbarem Cloud Hosting für professionelle IT-Infrastrukturen

How to Set the Timezone in Laravel

How to Set the Timezone in Laravel Laravel is a robust, object-oriented PHP framework designed to build modern, scalable web applications — from simple sites to complex enterprise-level solutions. It…