Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
VGSources
Blog

How to Install Python 3 and Set Up a Dev Environment on a Linux VPS

A practical Linux VPS guide to installing Python 3, creating per-project virtual environments, managing pip and PEP 668, selecting alternate Python versions, and deploying with secure interpreter paths.
Length11 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

On a Debian or Ubuntu VPS, install the distribution-supported Python 3 runtime with apt, add pip and venv, then create one virtual environment per project. Keep the operating system’s Python installation intact, install project packages only inside the environment, and configure production services to call the environment’s interpreter directly.

The sequence is: identify the distribution, install the supported packages, create and activate .venv, install and record dependencies, and verify every executable path. This avoids the “externally managed environment” error and prevents one project from changing another project’s dependencies.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What you need before installing Python

You need SSH access to the VPS, a user that can run sudo, and enough disk space for the interpreter, virtual environments, and your application. Perform development and deployment as a non-root user. Root should be reserved for operating-system changes and service administration.

  • SSH access: Connect to the server account that will own the project files.
  • Privilege: Confirm that account can run sudo. Do not make the application itself run as root.
  • A project location: The examples use ~/projects/myapp; choose a path appropriate for your deployment.
  • A supported package source: Use the VPS distribution’s package manager for the system interpreter and its tooling.

Python has two distinct roles on a Linux server. The system interpreter supports distribution utilities and may be required by package-management tools. A project interpreter, normally supplied by a virtual environment, runs your application’s code and third-party libraries. Treat those roles separately from the first command.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.

Identify the Linux distribution and existing Python

Do not assume that the command python exists or that it means Python 3. Check the operating system and the interpreter that is already installed:

cat /etc/os-release
python3 --version

/etc/os-release identifies the distribution and release family so you can use the correct package manager. python3 --version reports the interpreter available through the distribution’s normal command name. If the second command says that Python is not installed, continue with the package-installation step for your distribution.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

On Ubuntu, python3 tracks the release’s current default Python 3. That default is part of the operating system, not just an optional developer tool. Ubuntu explicitly warns: “Do not remove the default system installation of Python (the python3 package), as that would break system tooling.” Never delete or replace that package merely to obtain a newer language version.

Install Python 3, pip, and venv on Debian or Ubuntu

For a Debian- or Ubuntu-based VPS, update package metadata and install the complete Python runtime, pip, and the virtual-environment module:

sudo apt update
sudo apt install -y python3-full python3-pip python3-venv

python3-full supplies the standard runtime and commonly needed components, python3-pip supplies the package installer, and python3-venv supplies the module used to make isolated environments. Installing all three avoids a common partial setup in which Python works but venv or pip is missing.

Check the installation before creating a project:

python3 --version
python3 -m pip --version
python3 -m venv --help

Use python3 -m pip instead of relying on a separately named pip executable. The module form binds pip to the interpreter you selected, which is important when a server has more than one Python installation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When your VPS uses an RPM-based distribution

Distributions that use dnf or another package manager provide their own supported Python package names and release defaults. Use that distribution’s repositories for the system interpreter, pip, and venv-equivalent tooling; package names can vary by release. A typical dnf-based system exposes packages named along the lines of python3, python3-pip, and a venv module, but verify the exact names with the distribution’s package search before installing.

The design remains the same: keep the distribution interpreter for system tools, then create a per-project environment and use its interpreter for application packages. Do not copy Debian package commands unchanged onto an RPM-based VPS.

Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed

Create one isolated environment for each project

A virtual environment is a directory containing an interpreter and package-installation context that is separate from the system site-packages directory. Python 3.3 and later include venv; Python 3.4 and later environments include pip. Create the project directory and environment as the account that will own and run the application:

mkdir -p ~/projects/myapp
cd ~/projects/myapp
python3 -m venv .venv
source .venv/bin/activate
python --version
python -m pip --version

After source .venv/bin/activate, the shell prompt usually shows (.venv). The activation script prepends .venv/bin to PATH, so python and pip now refer to this project. Activation changes only the current shell; it does not permanently alter the server or other users’ shells.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Confirm that the shell selected the environment rather than the system interpreter:

which python3
command -v python3
command -v pip

The Python path should resolve inside your project, such as /home/your-user/projects/myapp/.venv/bin/python3. If it still points to /usr/bin/python3, activate the environment again from the project directory or invoke the interpreter by its full path.

To leave the environment, run:

deactivate

Removing a virtual environment does not remove the system Python or packages installed elsewhere. If an environment becomes unusable, deactivate it, delete only the project’s .venv directory, and recreate it from your dependency file.

Install dependencies with the project interpreter

Upgrade pip inside the activated environment, then install the project’s declared dependencies:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
python -m pip install --upgrade pip
python -m pip install -r requirements.txt

If the project does not yet have a requirements file, install its needed packages explicitly with python -m pip install package-name, test the application, and record the resulting set:

python -m pip freeze > requirements.lock.txt

Keep a dependency file in version control, but do not commit .venv. A requirements file communicates the intended inputs; a freeze-generated lock file records the exact versions observed in that environment. Use whichever convention your project follows, and regenerate the lock file deliberately when dependencies change rather than on every login.

Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)

Always run pip through the interpreter that will execute the application. The following two commands can target different installations when a machine has multiple Pythons:

Command What determines the target Safer project practice
pip install ... Whichever pip appears first in the current PATH Use only when you have verified the path
python -m pip install ... The exact python interpreter in the command Preferred inside an activated environment
/path/to/project/.venv/bin/python -m pip install ... An explicit, absolute interpreter path Best for scripts, cron jobs, and service units

Understand and fix “externally managed environment”

Current Debian and Ubuntu releases can mark the system Python environment as externally managed. A direct system-wide command such as sudo pip install some-package may fail with an externally-managed-environment message. This is a safety mechanism: the operating system’s package manager owns those files, and arbitrary pip upgrades can leave system tools with incompatible dependencies.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Follow the remedy stated by the error:

  • For a distribution-provided library: install the distribution package, commonly using a name such as python3-<name>, through apt.
  • For an application-specific library: create or activate a project virtual environment and run python -m pip install ... there.
  • For a standalone Python command-line application: use an isolated application installer such as pipx when it is available for your distribution and workflow.

Avoid adding --break-system-packages on a production VPS unless you fully understand the consequences for distribution-managed files and have a recovery plan. That option bypasses the protection; it does not make system-wide pip installs compatible with the package manager.

Choose between the distribution Python, pyenv, and a source build

The right installation method depends on whether you value distribution integration, project isolation, or access to multiple interpreter versions. The following comparison keeps those decisions separate:

Approach Distribution integration Isolation and version control Operational risk Use it when
Distribution packages (apt, dnf, and equivalents) Highest; updates and dependencies follow the VPS release Usually one release’s default Python; isolate projects with venv Lowest for system tooling when packages remain distribution-managed You want the supported runtime for ordinary applications and services
Virtual environment on the distribution Python System interpreter remains managed by the distribution Strong per-project package isolation; interpreter version follows the base Python Low; each environment can be rebuilt from a dependency file Most web apps, scripts, and services that support the VPS default Python
pyenv Lower; interpreters are managed outside the distribution package set Multiple Python versions can coexist and be selected per project More maintenance: each version and its build prerequisites must be maintained A project requires a Python version different from the distribution default
Self-compiled CPython Lowest unless you package and maintain it yourself Exact build and install prefix; combine with a venv for project packages Highest; you own updates, security fixes, build dependencies, and rollback You have a documented need that packages and pyenv cannot satisfy

Ubuntu documents pyenv as an option for selecting multiple Python versions. It is not a reason to remove the system python3; leave that interpreter available for operating-system tools and use the selected version for the application.

Use pyenv or a source build without destabilizing the VPS

When pyenv is appropriate

Choose pyenv when different projects genuinely require different Python releases and the distribution repositories do not provide those releases in a suitable form. Keep the pyenv-managed interpreter in the user or application scope, create a venv from that interpreter, and record which version the project expects. Test the full application, including native extensions and service startup, before changing production traffic.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Because pyenv builds or installs interpreters outside the distribution’s normal package lifecycle, you are responsible for updating each version and ensuring that the build remains compatible with the VPS. A version selector does not replace dependency isolation: still create one virtual environment per project.

When compiling CPython yourself

If you must compile CPython, install it into a separate prefix and follow Python’s Unix guidance to use make altinstall. altinstall places a versioned executable without replacing or masquerading as /usr/bin/python3. Do not point the system’s package-manager scripts at the custom build.

Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC

Build the interpreter separately from the production cutover. Verify the versioned executable, create a test virtual environment, install the application’s dependencies, run its tests, and exercise its startup and shutdown paths. Only then change a service to the new absolute interpreter path. Keep the previous interpreter available until rollback has been tested.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Verify paths, packages, and import locations

After activation, run a compact operational check. These commands expose the interpreter, package location, and installed package set:

command -v python3
command -v pip
python -m site
python -m pip list

command -v shows which executable the shell will run. python -m site displays the interpreter’s site-package directories, which helps detect a package accidentally installed outside the environment. python -m pip list shows what the selected environment can import.

For a script or service, do not rely on an interactive shell’s activation state. Use an absolute path such as /home/your-user/projects/myapp/.venv/bin/python in the launcher. This avoids failures caused by a different PATH under cron, an SSH command, or a service manager.

Run a VPS application with the environment’s interpreter

Development activation is convenient, but production should name the interpreter directly. A process supervisor or a systemd unit can invoke:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
/path/to/project/.venv/bin/python /path/to/project/app.py

Point the service’s working directory at the project, run it under a dedicated non-root service account, and keep secrets out of source control. The service account needs read and execute access to the application and write access only where the application actually stores data or logs.

When you deploy a new release, create or update the environment in a controlled location, install from the committed dependency file, run checks, and then change the service to the new absolute path if you use release directories. Keep the old environment until the new process has started successfully and a rollback is possible.

Secure the Python installation on a VPS

  • Use least privilege: Install packages as the project owner inside its environment. Avoid running pip with sudo.
  • Separate service accounts: A service should not share a writable home directory with unrelated applications.
  • Protect SSH: Apply the VPS provider’s SSH-hardening guidance, restrict administrative access, and use key-based authentication where appropriate.
  • Limit network exposure: Configure the firewall so only required service ports are reachable. A Python environment does not secure an accidentally exposed database or debug endpoint.
  • Review dependencies: Install from the project’s declared files, update them deliberately, and inspect changes before deploying.
  • Keep the host maintained: Continue applying distribution security updates. A venv isolates Python packages; it does not patch the kernel, OpenSSH, or other system services.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common installation problems

python is not found

Use python3 before activation. Once the environment is active, python should resolve to .venv/bin/python. If it does not, check command -v python and activate the environment from the correct directory.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.

python3 -m venv .venv fails

On Debian or Ubuntu, install the missing module with:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo apt update
sudo apt install -y python3-venv

Then remove only the incomplete project directory and run the venv command again. If the distribution uses another package manager, install its venv-equivalent package instead of mixing package-manager families.

pip installs into the wrong location

Activate the environment and compare:

command -v python
command -v pip
python -m pip --version

All paths should refer to the same .venv. Replace bare pip with python -m pip in scripts and deployment instructions. For maximum certainty, use the environment’s absolute interpreter path.

The externally managed error appears

You are probably invoking pip against the system interpreter. Create and activate .venv, then repeat the install with python -m pip. If you intentionally need a distribution package, install it with the distribution package manager. Do not bypass the protection reflexively with --break-system-packages.

A package builds successfully but the service cannot import it

Compare the interpreter used during installation with the one used by the service. Run /path/to/project/.venv/bin/python -m pip list and start the application with that same absolute path. An interactive shell may have an activated environment while systemd or cron does not.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A newer Python version is required

First check whether the project supports the VPS distribution’s default Python. If not, use pyenv for a user-managed version or compile CPython into a separate prefix. Create a venv from the selected version, test the application, and switch the production service only after validation. Leave the distribution’s python3 untouched.

The environment works for one user but not another

Virtual environments are directories with ownership and permissions. Activate the environment as the account that owns it, or create a separate environment for the service account. Do not make a shared environment broadly writable; that would let one user alter another user’s executable code.

A repeatable setup checklist

  1. Log in with the intended non-root account and confirm sudo access.
  2. Run cat /etc/os-release and python3 --version.
  3. Install the supported runtime and tools. On Debian or Ubuntu, run sudo apt update followed by sudo apt install -y python3-full python3-pip python3-venv.
  4. Create the project directory and environment with python3 -m venv .venv.
  5. Activate it and verify python --version, python -m pip --version, and the executable paths.
  6. Upgrade pip and install dependencies using python -m pip.
  7. Record dependencies with the project’s requirements or lock-file convention, and exclude .venv from version control.
  8. Run command -v python3, command -v pip, python -m site, and python -m pip list.
  9. Configure the process supervisor or systemd to call /path/to/project/.venv/bin/python directly.
  10. Test the service as its non-root account, confirm firewall and SSH controls, and retain a rollback path before introducing traffic.

Which setup should you choose?

For the majority of Linux VPS projects, use the distribution’s Python 3 package plus one venv per project. This keeps system tooling under the package manager while giving your application independent dependencies. Add pyenv only when you need multiple Python releases, and compile CPython yourself only when a documented requirement justifies the additional maintenance and rollback work.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.