On this pageCheck what the server already has
Installing Python on a server is rarely about getting Python. Most Linux images already have it, and the real job is keeping your application's packages away from the copy the operating system depends on. On Windows the question changed recently: the classic installer is on its way out, and the Python install manager replaces it. This guide covers both, with the commands that hold up on a production server.
Check what the server already has
On Linux, look before you install:
python3 --version
command -v python3
The version depends on the distribution, not on what is newest:
| System | Default python3 |
|---|---|
| Ubuntu 24.04 LTS | 3.12 |
| Ubuntu 26.04 LTS | 3.14 |
| Debian 12 | 3.11 |
| Debian 13 | 3.13 |
| Windows Server | None installed |
Then check which release lines are still supported, because "installed" and "maintained" are different things:
| Version | Status in November 2026 | Supported until |
|---|---|---|
| 3.15 | Bug fixes (first release October 2026) | October 2031 |
| 3.14 | Bug fixes | October 2030 |
| 3.13 | Security fixes only | October 2029 |
| 3.12 | Security fixes only | October 2028 |
| 3.11 | Security fixes only | October 2027 |
| 3.10 | End of life since October 2026 | None |
If the distribution's version is supported and your dependencies run on it, use it. Reach for a newer interpreter only when the project needs one.
Linux: use the system Python, never pip into it
Debian and Ubuntu mark their Python as managed by the package manager. Run pip install against it and you get error: externally-managed-environment. That refusal protects tools such as apt helpers and cloud-init from a library upgrade they did not ask for. Do not bypass it with --break-system-packages; give each application its own virtual environment instead.
sudo apt update
sudo apt install -y python3-venv python3-pip
# a system user and a home for the app
sudo useradd --system --home-dir /opt/myapp --shell /usr/sbin/nologin myapp
sudo install -d -o myapp -g myapp /opt/myapp
# the virtual environment belongs to that user
sudo -u myapp python3 -m venv /opt/myapp/.venv
sudo -u myapp /opt/myapp/.venv/bin/pip install -r /opt/myapp/requirements.txt
Without python3-venv, python3 -m venv fails with a message about ensurepip. You never need to "activate" an environment on a server: calling /opt/myapp/.venv/bin/python uses it directly, which is exactly what a service file should do.
Linux: a newer Python with uv
When the project needs a newer interpreter than the distribution ships, do not replace /usr/bin/python3. Install a separate one next to it. uv, a fast package and Python manager written in Rust, downloads prebuilt interpreters and manages environments in one tool:
# installs uv and uvx into ~/.local/bin (read the script first if you prefer)
curl -LsSf https://astral.sh/uv/install.sh | sh
uv python install 3.15
uv python list
# a virtual environment on that interpreter
uv venv --python 3.15 /opt/myapp/.venv
uv pip install --python /opt/myapp/.venv/bin/python -r requirements.txt
uv keeps the interpreters it downloads under ~/.local/share/uv/python for the user who ran it, so run these commands as the account that owns the app, or set UV_PYTHON_INSTALL_DIR to a shared directory. For projects with a pyproject.toml, uv sync creates .venv and installs exactly what uv.lock pins, which is what you want on a server. Standalone installs update with uv self update.
Compiling Python from source with make altinstall still works, but every security release then means another compile. Prebuilt interpreters save that work.
Windows Server: the Python install manager
The full Python installer is deprecated since 3.14: 3.15 is the last version that ships it, and it will not be produced for 3.16 or later. Its replacement is the Python install manager, which provides the py, python and pymanager commands and installs runtimes on demand.
On Windows Server 2022 and 2025, install it from the MSIX on python.org (double-click it, or Add-AppxPackage <file>). Windows Server 2025 also includes winget, which appears after the first sign-in:
winget install 9NQ7512CXL7T -e --accept-package-agreements --disable-interactivity
py install --configure -y
Then add a runtime and build the environment:
py install 3.15
py list
py -V:3.15 -m venv C:\apps\myapp\.venv
C:\apps\myapp\.venv\Scripts\python.exe -m pip install -r C:\apps\myapp\requirements.txt
Two server details matter:
- Windows Server 2019 cannot install MSIX packages. Use the MSI from python.org instead; it has no interface and installs the manager per machine.
- Runtimes are per user. A runtime installed in your profile is invisible to a service running as another account. For services, extract a runtime to a shared folder as administrator with
py install --target=C:\Python315 3.15. The manager does not track that copy, so runC:\Python315\python.exedirectly, including to create the service's virtual environment.
To move installed runtimes to the newest patch release, run py install --update. Virtual environments built on them are not touched, so recreate one only when you change minor versions.
Run the app as a service
On Linux, a systemd unit pointing at the environment's interpreter is all it takes:
# /etc/systemd/system/myapp.service
[Unit]
Description=myapp
After=network-online.target
Wants=network-online.target
[Service]
User=myapp
WorkingDirectory=/opt/myapp
ExecStart=/opt/myapp/.venv/bin/python -m myapp
Restart=on-failure
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now myapp
journalctl -u myapp -f
On Windows, a scheduled task that starts at boot is the simplest built-in option. Run it under a dedicated low-privilege account, and let PowerShell prompt for the password so it never lands in your shell history:
$cred = Get-Credential -Message 'Account that runs myapp'
$action = New-ScheduledTaskAction -Execute 'C:\apps\myapp\.venv\Scripts\python.exe' -Argument '-m myapp' -WorkingDirectory 'C:\apps\myapp'
$trigger = New-ScheduledTaskTrigger -AtStartup
Register-ScheduledTask -TaskName 'myapp' -Action $action -Trigger $trigger -User $cred.UserName -Password $cred.GetNetworkCredential().Password
Every command here runs as written on a CloudSat Cloud VPS with Ubuntu or Debian, or on a Windows VPS where you have full administrator rights.
Fix the errors you will meet
fatal error: Python.h: No such file or directorywhile a package builds: the development headers are missing. On Debian and Ubuntu, runsudo apt install python3-dev build-essential, then retry inside the environment.- The app works in your shell but fails under systemd with
ModuleNotFoundError: the unit runs a different interpreter.systemctl cat myappprints theExecStartline, which must name the environment'spython, not/usr/bin/python3. pythonopens the Microsoft Store, or does nothing, on Windows: open Manage app execution aliases in Settings and enable the entries for Python and the Python install manager.pyis not recognized in a new terminal:%UserProfile%\AppData\Local\Microsoft\WindowsAppsis missing fromPATH. Ifpyinstead reports that it can't open a file, an older Python launcher is still installed; remove it from Installed apps.- Two Pythons fight over
python.exe: remove installs made with the old full installer before relying on the install manager, or call each interpreter by its full path.
Keep the interpreter patched
Security fixes arrive as patch releases, such as 3.15.1 to 3.15.2. The distribution's Python gets them with your normal package updates, so automatic security updates cover it. For an interpreter installed with uv, install the new patch release and recreate the environment from it; with a lock file that takes seconds. On Windows, py install --update handles the runtimes the manager knows about. A copy extracted with --target is not tracked, so extract the new release into a fresh folder, recreate the service's environment from it and switch the task over.
FAQ
Should python point to Python 3 on Linux?
On Debian and Ubuntu, sudo apt install python-is-python3 makes python an alias for python3. Scripts you write for a server should still call python3 or, better, the interpreter inside their virtual environment.
Can I upgrade the system Python to a newer version?
Not safely. Changing /usr/bin/python3, for example with update-alternatives, breaks tools that were tested against the distribution's version. Install the newer interpreter next to it with uv and point the application at it.
Do I still need pip if I use uv?
Not for your own work: uv replaces pip, venv and pipx for most tasks, and uv pip install accepts the familiar arguments. Keep pip inside environments where a script or tool calls it directly.
Is Anaconda a better choice on a server?
Conda environments help with data-science stacks that bundle compiled libraries, but check the license terms before running Anaconda's channels in an organization. Our guide to Anaconda licensing and server alternatives covers the options.
Run it on CloudSat. Cloud VPS on AMD EPYC and NVMe from $1.98/mo in 13 regions, delivered in under 5 minutes and paid in crypto. See plans or deploy a server.




