To install Python Ubuntu server tooling safely, use Ubuntu’s packaged python3 ecosystem, install the fuller runtime and pip tooling with apt, then create a virtual environment for each project. That approach keeps the system Python stable while giving your application a clean place for packages.
Most modern Ubuntu Server images already include a basic python3 interpreter because system tools depend on it. The practical installation task is usually to add the complete runtime, pip, and virtual environment support without damaging the OS-managed Python installation.
This tutorial is written for VPS admins and developers who need Python for web apps, automation scripts, data jobs, or deployment tooling on Ubuntu.
Key takeaways
- Do not remove Ubuntu’s default
python3package; Ubuntu warns that doing so can break system tooling. - Use
python3-fullwhen you want the interpreter, full standard-library support, and venv tooling from Ubuntu packages. - Install pip through Ubuntu packages, then use project virtual environments for application dependencies.
- Use
python3 -m venvinstead of installing project packages into the system Python environment. - Verify both the interpreter and pip inside the virtual environment before deploying code.
- For related VPS workflows, see the Virtarix guides to Linux command line habits, managing packages with apt, and how to secure a VPS.
Before you install: understand system Python
Ubuntu uses Python for operating-system tooling, so the default python3 package is not just another optional developer package. Treat it as part of the OS. Removing it can break tools that Ubuntu expects to be present.
That is why the safest install python ubuntu workflow does not replace or delete the system Python. It adds the supported packages you need, then isolates project dependencies in a virtual environment.
This separation matters on a VPS. A web app may need one set of Python packages, a backup script may need another, and the operating system may depend on its own packaged modules. Keeping those layers separate makes upgrades and troubleshooting easier.
Safe install steps
Step 1: Update apt package lists
Start by refreshing apt metadata so the server sees the current package information for its configured Ubuntu repositories.
apt-get update
If you normally administer the server as a non-root user, run the command with your usual privilege escalation method. In the verification container for this workflow, the command ran as root inside a disposable Ubuntu image.
Step 2: Install the full Python runtime and pip tooling
Install Ubuntu’s full Python runtime package plus pip tooling.
apt-get install -y python3-full python3-pip
Ubuntu’s Python setup documentation describes python3-full as the fuller runtime package with the interpreter, complete class library, virtual environment support, and IDLE. python3-pip provides pip from Ubuntu packages.
This is the best default for a VPS where you want reliable Python tooling without bypassing the distribution’s package manager.
Step 3: Check the installed Python version
Confirm that the interpreter is available.
python3 --version
The exact version depends on the Ubuntu release and repository state. For example, Ubuntu 24.04 uses a Python 3.12 series package by default, while older LTS releases ship older Python 3 versions. Avoid hard-coding a version unless your application truly requires it.
Step 4: Create a project virtual environment
Create a virtual environment inside your project directory or a dedicated application path.
python3 -m venv /tmp/vxpy
Python’s venv documentation explains that virtual environments create an isolated Python environment and, unless disabled, bootstrap pip into that environment. On a real project, replace /tmp/vxpy with a project path such as .venv in your app directory.
Step 5: Use pip from inside the virtual environment
Verify pip inside the virtual environment before installing project packages.
/tmp/vxpy/bin/python -m pip --version
Using python -m pip from the virtual environment keeps the interpreter and package installer aligned. That prevents a common VPS mistake: installing a package with one pip executable and running the app with another Python interpreter.
For interactive development, you can activate the environment in your shell. For system services, it is often clearer to point the service directly at the virtual environment’s Python path.
What to do on different Ubuntu versions
The workflow is the same across supported Ubuntu Server releases: use apt for Ubuntu-managed Python packages, then use a virtual environment for application dependencies. The exact Python minor version changes by release.
For Ubuntu 24.04, expect Python 3.12 series packages from the standard repositories. For older LTS releases, expect older Python 3 minor versions. If you need a specific Python minor version, decide whether the application truly requires it, then document the source you use. Do not replace the system Python just to satisfy one project.
If a project requires a newer Python than the OS provides, use a project-specific method such as a container, a dedicated runtime manager, or a separate interpreter path. Keep that separate from /usr/bin/python3 so Ubuntu’s own tooling stays predictable.
Avoid global pip installs on servers
The Python Packaging User Guide recommends virtual environments for package installation workflows. That guidance is especially important on a server because global pip installs can mix application packages with OS-managed Python packages.
A virtual environment gives each app its own dependency set. If a package upgrade breaks one project, it does not automatically affect the system Python or another application on the same VPS.
This pattern also helps deployment. You can rebuild a virtual environment from a requirements file, test it on staging, then move the same dependency set to production.
Troubleshooting common install issues
python3 already exists
That is normal on Ubuntu Server. Keep it. Install the extra runtime and tooling you need instead of removing the default package.
python3 -m venv fails
Install the fuller Python runtime package from Ubuntu repositories, then try the virtual environment command again. The python3-full package is the simplest default because it pulls in venv support and the fuller standard-library environment.
pip installs packages but the app cannot import them
You may be using pip from one Python environment and running the app with another. Use the virtual environment’s Python executable with -m pip, then run the app with that same virtual environment.
A tutorial says to use python instead of python3
On Ubuntu, use python3 in server instructions unless your environment explicitly provides a python command for Python 3. Being explicit avoids ambiguity on systems with legacy tooling.
Safer VPS checklist
Before installing Python packages on a production VPS, confirm:
- the Ubuntu release and default Python version;
- whether the app needs a specific Python minor version;
- whether the app has its own virtual environment;
- whether dependencies are pinned in a requirements file or lock file;
- whether the service uses the virtual environment path;
- whether staging and production use the same install steps.
That checklist is short, but it prevents two common problems: accidentally changing the system Python and installing packages into the wrong environment.
If you want a clean server for Python web apps, automation, or staging environments, Virtarix Cloud VPS plans give you isolated Ubuntu servers where you can install Python, test virtual environments, and keep experiments separate from production.
FAQ
What is the best way to install Python on Ubuntu Server?
Use Ubuntu packages for the runtime and tooling, then install application dependencies inside a virtual environment. A practical default is python3-full plus python3-pip, followed by python3 -m venv for each project.
Should I remove the default Python version first?
No. Ubuntu warns not to remove the default python3 package because system tooling depends on it. Add project-specific tooling without replacing the OS-managed interpreter.
Should I use pip globally or inside a virtual environment?
Use pip inside a virtual environment for application packages. This keeps project dependencies separate from the operating system and from other applications on the same VPS.
Summary
The safest install python ubuntu workflow is to keep Ubuntu’s system Python intact, install supported packages with apt, and use a virtual environment for every project. That gives you a predictable interpreter, working pip, and a clean dependency boundary between the OS and your application.
On a VPS, that boundary is what makes Python maintenance manageable. You can upgrade, rebuild, or remove one project environment without risking the server’s own Python tooling.
Byline: Peter French — Updated 2026-05-18.