Python ranks among the world’s top programming languages thanks to its clear, concise syntax and an extensive library ecosystem. From crafting web applications and automating daily tasks to performing data analysis and experimenting with machine learning, Python’s versatility and readability let you prototype rapidly and maintain clean, efficient code.
In this guide, you’ll learn how to install Python on Windows, handle multiple versions using tools like pyenv-win or the system installer, and create virtual environments to keep dependencies isolated. We’ll cover pip for package management, demonstrate your first Python script, and show you how to configure an IDE or code editor for a seamless development experience on Windows.
Before you begin installing Python on Windows, ensure your system is up to date. You’ll need a stable internet connection, administrator privileges, and enough disk space to install Python and its related tools. Most modern Windows machines meet these requirements by default.
While Python doesn’t rely on other software to run basic scripts, you might later want to install additional development tools like a code editor (e.g., VS Code) or Git for version control. We’ll cover those in a later section.
To install Python on Windows, head to the official website at python.org and download the latest stable version for Windows. Run the installer, and make sure to check the box that says “Add Python to PATH” before proceeding with the installation.
Follow the installation wizard steps, and once complete, you can confirm Python is installed by opening Command Prompt and running: python --version
. This should return the version number of Python that you just installed.
On Windows, Python environments can be managed using the built-in venv
module to create isolated environments for your projects. You can create one by running: python -m venv myenv
, which sets up a standalone Python environment in the myenv
directory.
If you need to manage multiple Python versions, tools like pyenv-win can help. It's a Windows port of the popular Unix pyenv
, letting you install and switch between versions easily. Follow the pyenv-win installation guide to get started.
After installing Python on Windows, open a new Command Prompt or PowerShell window and run the following commands to confirm that Python and pip are correctly installed:
python --version pip --version
If both commands return version numbers (e.g., Python 3.12.1
and pip 23.0.1
), your installation is verified. If not, ensure that “Add Python to PATH” was checked during setup or adjust your system PATH environment variable accordingly.
By default, pip is installed alongside Python. To upgrade pip to the latest version, run:
python -m pip install --upgrade pip
For global CLI tools, install pipx and add its user‐level bin directory to your PATH:
python -m pip install --user pipx python -m pipx ensurepath
To create isolated project environments, use the built-in venv module:
python -m venv .\myenv .\myenv\Scripts\activate
When you’re done, deactivate with:
deactivate
The Python REPL lets you execute Python commands interactively. Launch it by typing:
python
You’ll see the prompt >>
, where you can enter expressions:
>> print("Hello from REPL!") Hello from REPL!
Exit the shell by typing exit()
or pressing Ctrl+Z then Enter.
Open your text editor of choice (e.g., Notepad, Visual Studio Code, or Sublime Text) and create a new file named hello.py
. In that file, add the following line:
print("Hello, Python on Windows!")
Save the file, then open Command Prompt or PowerShell, navigate to the folder containing hello.py
, and run:
python hello.py
If everything is set up correctly, you’ll see Hello, Python on Windows!
printed in your terminal.
For a robust editing experience, Visual Studio Code is highly recommended. Install the “Python” extension from Microsoft (and optionally “Pylance” for enhanced IntelliSense) via the Extensions pane. This adds syntax highlighting, code completion, linting, and debugging support.
After installing the extension, open your workspace in VS Code, press Ctrl+Shift+P, choose “Python: Select Interpreter,” and pick the Python installation or virtual environment you want to use. Configure linting tools like flake8
and formatters like black
in your settings to maintain clean, consistent code.
Start by creating a project folder and navigating into it from Command Prompt or PowerShell:
mkdir my_python_project
cd my_python_project
Then set up a virtual environment within that folder and activate it:
python -m venv venv
.\venv\Scripts\activate
Create your main script file, for example app.py
, and begin writing your Python code. If you have dependencies, list them in a requirements.txt
file and install with:
pip install -r requirements.txt
Now that your project structure is in place, explore adding functionality by installing popular packages like requests
or flask
. Practice by building small scripts, web applications, or command-line tools to solidify your skills.
For further learning, check out the official Python Tutorial, interactive courses on LearnPython.org, and community challenges on Exercism. Joining forums like r/learnpython on Reddit can also help you stay motivated and get answers to your questions.