How to Install Python on Windows Server 2025

Python is one of the most versatile programming languages in modern IT, widely used for automation scripts, data processing pipelines, REST APIs built with Flask or FastAPI, machine learning workloads, and infrastructure tooling. Windows Server 2025 does not include Python by default, so administrators need to install and configure it explicitly. This tutorial covers installing Python from the official installer, performing silent automated installations for large-scale deployments, updating pip, creating and activating virtual environments to isolate project dependencies, installing Python via Chocolatey, managing packages, scheduling Python scripts with Windows Task Scheduler, and running Python scripts as persistent Windows Services using the pywin32 library.

Prerequisites

  • Windows Server 2025 with administrative privileges
  • PowerShell 5.1 or PowerShell 7.x
  • Internet access or an internal package mirror
  • At least 200 MB of disk space per Python installation

Step 1: Install Python from python.org

The official Python installer from python.org provides the most reliable and up-to-date release for Windows. The graphical installer presents an option to add Python to PATH during setup — always enable this when installing on servers to avoid manually updating environment variables.

# Download the latest Python 3.13 installer
$pythonVersion = "3.13.3"
$installerUrl  = "https://www.python.org/ftp/python/$pythonVersion/python-$pythonVersion-amd64.exe"
$installerPath = "C:Temppython-$pythonVersion-amd64.exe"

Invoke-WebRequest -Uri $installerUrl -OutFile $installerPath -UseBasicParsing

# Run interactive installer
# During setup, check:
#   [x] Add Python 3.13 to PATH
#   [x] Install for all users (requires admin)
Start-Process -FilePath $installerPath -Wait

# Verify installation
python --version
python -c "import sys; print(sys.executable)"

Step 2: Silent Installation for Automated Deployment

When provisioning multiple servers or using configuration management tools, use the Python installer in quiet mode with command-line flags that mirror the interactive options. Silent installation is idempotent and can be scripted into any deployment pipeline.

# Silent install — system-wide, adds Python to PATH, no shortcuts
$pythonVersion = "3.13.3"
$installerPath = "C:Temppython-$pythonVersion-amd64.exe"

Start-Process -FilePath $installerPath -ArgumentList @(
    "/quiet",
    "InstallAllUsers=1",
    "PrependPath=1",
    "Include_test=0",
    "Include_doc=0",
    "Include_launcher=1",
    "AssociateFiles=1",
    "DefaultJustForMeTargetDir=C:Python313"
) -Wait -PassThru

# Reload PATH in current session
$env:PATH = [Environment]::GetEnvironmentVariable("PATH", "Machine")

# Verify
python --version
where.exe python

# Unattended install via winget (alternative)
winget install Python.Python.3.13 --silent --accept-package-agreements --accept-source-agreements

Step 3: Update pip and Verify Package Manager

pip is Python’s package installer and ships bundled with every Python 3.x installation. Always update it immediately after installing Python to ensure you have the latest dependency resolution and security fixes.

# Upgrade pip to the latest version
python -m pip install --upgrade pip

# Verify pip version
python -m pip --version

# List installed packages
python -m pip list

# Install pip into a Python installation that is missing it
python -m ensurepip --upgrade

# Configure pip to use a corporate PyPI mirror (for environments without direct internet)
$pipConf = @"
[global]
index-url = https://pypi.internal.example.com/simple/
trusted-host = pypi.internal.example.com
timeout = 60
"@
$pipConfDir = "$env:APPDATApip"
New-Item -ItemType Directory -Path $pipConfDir -Force | Out-Null
$pipConf | Set-Content "$pipConfDirpip.ini" -Encoding UTF8

# Verify the mirror is used
python -m pip config list

Step 4: Create and Use Virtual Environments

Virtual environments isolate Python dependencies on a per-project basis, preventing version conflicts between applications hosted on the same server. Every production Python application should run inside its own virtual environment.

# Create a virtual environment in the project directory
Set-Location "C:AppsMyPythonApp"
python -m venv .venv

# Activate the virtual environment (PowerShell)
..venvScriptsActivate.ps1

# Activate in cmd.exe (for batch files or Task Scheduler)
# .venvScriptsactivate.bat

# After activation, the prompt changes to show (.venv)
# All pip installs now go into .venv, not the system Python
pip install requests flask gunicorn

# Generate a requirements file to lock dependencies
pip freeze > requirements.txt

# Replicate the environment on another server
python -m venv .venv
..venvScriptsActivate.ps1
pip install -r requirements.txt

# Deactivate when done
deactivate

# PowerShell execution policy may need updating to allow scripts
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Step 5: Install Python via Chocolatey

Chocolatey is a Windows package manager that simplifies installing and keeping Python up to date across a fleet of servers. It integrates well with CI/CD pipelines and configuration management tools.

# Install Chocolatey (if not already present)
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

# Refresh environment variables
$env:PATH = [Environment]::GetEnvironmentVariable("PATH", "Machine")

# Install the latest Python 3 via Chocolatey
choco install python --yes

# Install a specific version
choco install python313 --yes

# Upgrade Python when a new release is available
choco upgrade python --yes

# List installed Chocolatey packages
choco list --local-only | Select-String "python"

# Verify
python --version

Step 6: Install and Manage Python Packages

Installing the right packages and keeping them updated is an ongoing operational task. Use pip within virtual environments for application-specific packages and maintain a requirements.txt for reproducible deployments.

# Install common server-side packages
pip install requests          # HTTP client
pip install flask             # Lightweight web framework
pip install fastapi uvicorn   # Async web framework
pip install sqlalchemy        # ORM for database access
pip install psycopg2-binary   # PostgreSQL adapter
pip install pyodbc            # ODBC database driver for SQL Server
pip install pywin32           # Windows-specific APIs (services, registry, COM)
pip install schedule          # Lightweight job scheduler

# Install a specific version
pip install "requests==2.32.3"

# Install from a private Git repository
pip install "git+https://github.com/example/mypackage.git@main"

# Check for outdated packages
pip list --outdated

# Upgrade all outdated packages
pip list --outdated --format=json |
    python -c "import json,sys; [print(p['name']) for p in json.load(sys.stdin)]" |
    ForEach-Object { pip install --upgrade $_ }

# Uninstall a package
pip uninstall flask --yes

Step 7: Schedule Python Scripts with Windows Task Scheduler

Windows Task Scheduler is the native tool for running Python scripts on a recurring schedule — suitable for ETL jobs, report generation, health checks, and maintenance tasks. Always point the Task Scheduler action at the virtual environment’s Python executable to ensure the correct interpreter and packages are used.

# Register a scheduled task that runs a Python script every 15 minutes
$pythonExe  = "C:AppsMyPythonApp.venvScriptspython.exe"
$scriptPath = "C:AppsMyPythonApprun_task.py"
$logPath    = "C:LogsMyPythonApptask.log"

New-Item -ItemType Directory -Path "C:LogsMyPythonApp" -Force | Out-Null

$action  = New-ScheduledTaskAction `
    -Execute $pythonExe `
    -Argument "`"$scriptPath`" >> `"$logPath`" 2>&1" `
    -WorkingDirectory "C:AppsMyPythonApp"

$trigger = New-ScheduledTaskTrigger -RepetitionInterval (New-TimeSpan -Minutes 15) -Once `
    -At (Get-Date).Date

$settings = New-ScheduledTaskSettingsSet `
    -ExecutionTimeLimit (New-TimeSpan -Hours 1) `
    -RestartCount 3 `
    -RestartInterval (New-TimeSpan -Minutes 5) `
    -StartWhenAvailable

$principal = New-ScheduledTaskPrincipal `
    -UserId "NT AUTHORITYSYSTEM" `
    -LogonType ServiceAccount `
    -RunLevel Highest

Register-ScheduledTask `
    -TaskName "MyPythonApp-Scheduled" `
    -Action $action `
    -Trigger $trigger `
    -Settings $settings `
    -Principal $principal `
    -Force

# Test the task immediately
Start-ScheduledTask -TaskName "MyPythonApp-Scheduled"
Get-ScheduledTaskInfo -TaskName "MyPythonApp-Scheduled"

Step 8: Run a Python Script as a Windows Service Using pywin32

For long-running Python processes — such as background queue workers, monitoring daemons, or API servers — running as a Windows Service provides automatic startup, restart-on-failure, and integration with the Windows Services control panel. The pywin32 package provides the necessary Windows service base class.

# Install pywin32 in the virtual environment
..venvScriptsActivate.ps1
pip install pywin32

# Post-install step required for pywin32 to register itself
python .venvScriptspywin32_postinstall.py -install

Create the service script at C:AppsMyPythonAppwin_service.py:

import win32serviceutil
import win32service
import win32event
import servicemanager
import socket
import time
import logging

logging.basicConfig(
    filename=r"C:LogsMyPythonAppservice.log",
    level=logging.INFO,
    format="%(asctime)s %(levelname)s %(message)s",
)

class MyPythonService(win32serviceutil.ServiceFramework):
    _svc_name_        = "MyPythonService"
    _svc_display_name_ = "My Python Background Service"
    _svc_description_  = "Runs the MyPythonApp background worker."

    def __init__(self, args):
        win32serviceutil.ServiceFramework.__init__(self, args)
        self.stop_event = win32event.CreateEvent(None, 0, 0, None)
        self.running = True

    def SvcStop(self):
        self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
        win32event.SetEvent(self.stop_event)
        self.running = False
        logging.info("Service stop requested.")

    def SvcDoRun(self):
        servicemanager.LogMsg(
            servicemanager.EVENTLOG_INFORMATION_TYPE,
            servicemanager.PYS_SERVICE_STARTED,
            (self._svc_name_, ""),
        )
        logging.info("Service started.")
        self.main()

    def main(self):
        while self.running:
            # Replace with your actual worker logic
            logging.info("Worker heartbeat.")
            time.sleep(30)

if __name__ == "__main__":
    win32serviceutil.HandleCommandLine(MyPythonService)
# Install, start, and verify the Windows Service
$pythonExe = "C:AppsMyPythonApp.venvScriptspython.exe"

# Install the service (registers it in the SCM)
& $pythonExe "C:AppsMyPythonAppwin_service.py" install

# Set the service to start automatically and configure failure recovery
sc.exe config MyPythonService start= auto
sc.exe failure MyPythonService reset= 86400 actions= restart/5000/restart/10000/restart/30000

# Start the service
Start-Service -Name "MyPythonService"
Get-Service  -Name "MyPythonService"

# View logs
Get-Content "C:LogsMyPythonAppservice.log" -Tail 20 -Wait

Conclusion

Python on Windows Server 2025 is a first-class citizen with excellent tooling support. The official installer handles PATH configuration and launcher registration cleanly, while the silent install flags make automated deployments reproducible across server fleets. Virtual environments are non-negotiable in production: they prevent dependency conflicts, make deployments deterministic via requirements.txt, and allow multiple Python applications to coexist on the same server without interfering with one another. Chocolatey provides a streamlined upgrade path for keeping Python current. Windows Task Scheduler is the right tool for periodic batch jobs, and pywin32 unlocks full Windows Service integration for long-running daemon processes that need automatic startup, restart-on-failure, and proper lifecycle management through the Services control panel. With these techniques, Python becomes a fully managed, enterprise-grade runtime on Windows Server 2025.