Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon 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
World desk7 min

How to Create a Python Virtual Environment on a Linux VPS

Install the venv package, create .venv with the intended Python interpreter, activate it, install requirements with the environment's pip, and troubleshoot missing venv or ensurepip errors on a Linux VPS.

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.

On an Ubuntu or Debian VPS, install the distribution’s venv package, create an environment in your project directory, activate it, and install packages through its own pip. The usual sequence is:

sudo apt update
sudo apt install python3-venv
cd ~/projects/myproject
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
# leave the environment when finished
deactivate

The environment uses the exact Python interpreter that runs python3 -m venv. On Ubuntu and Debian, omitting the venv package commonly produces No module named venv; a Python build without ensurepip instead reports that ensurepip is unavailable.

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 a virtual environment does on a VPS

A Python virtual environment is a project-specific directory containing an isolated Python installation context. Its bin directory contains a copy or symlink of the interpreter and environment-specific command-line tools. A pyvenv.cfg file records the base Python installation, including the home location used to create the environment.

When the environment is active, the shell’s PATH is rewritten so python and pip resolve to that directory rather than the operating system’s commands. This keeps an application’s packages separate from packages needed by the operating system or another application. It does not create a second kernel, virtual machine, or operating-system user; it is a Python-level isolation mechanism.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

The official reference for creation flags and version-specific behavior is the Python documentation at docs.python.org/3/library/venv.html. Check the documentation matching the Python version installed on your VPS.

Before you begin

  • Use a shell account that can run sudo for package installation, or ask the VPS administrator to install the package.
  • Know which Python executable your application should use. The command you invoke determines the environment’s Python version.
  • Have a project directory with a writable location for the environment. .venv and venv are conventional names; the directory may also be placed elsewhere, such as ~/projects/myproject/venv.
  • The commands below focus on Ubuntu and Debian. Package names and installation procedures for RHEL, Fedora, Alpine, and other distributions are different and are not covered here.

Step 1: install the venv package

Ubuntu and Debian package the venv module separately from the main Python executable. Install it before creating an environment:

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 python3-venv

If your distribution asks for confirmation, approve the installation. You can check the interpreter that will be used with:

python3 --version
command -v python3

For a version-specific interpreter, install the matching package when your distribution provides one. For example, an interpreter named python3.11 may require the corresponding python3.11-venv package rather than the generic package.

Step 2: move to the project directory

Create or select the directory that will contain your application, then change into it:

mkdir -p ~/projects/myproject
cd ~/projects/myproject

Keeping .venv inside the project makes activation commands predictable and lets deployment scripts refer to one known path. You can choose another absolute path when several projects share a dedicated environment location.

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

Step 3: create the environment

Run the module through the interpreter you intend to use:

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
python3 -m venv .venv

The command creates the target directory and its parent directories when needed. It also writes pyvenv.cfg and creates bin, where the environment’s interpreter and scripts live. On Linux, the activation script is .venv/bin/activate.

Because the interpreter is selected before -m venv, this command creates a Python 3 environment using whichever executable python3 resolves to. If several versions are installed, invoke the desired one explicitly:

python3.11 -m venv .venv

Do not reuse an environment created with a different interpreter and assume its version changed. Create a new environment, or use the documented upgrade behavior for the same installation when appropriate.

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

Step 4: activate it in your current shell

From the project directory, run:

source .venv/bin/activate

The shell prompt normally gains the environment name in parentheses, such as (.venv). Activation changes command lookup for that shell session; it does not alter the VPS globally. Confirm the result instead of relying only on the prompt:

command -v python
command -v pip
python --version
python -c "import sys; print(sys.executable)"

The reported executable paths should point inside your project’s .venv/bin/ directory. If they still point to a system path, the activation command was run in a different shell, failed, or the shell’s command lookup needs to be checked again.

Step 5: install application dependencies

Once activated, use the environment’s package installer. Calling pip through the active interpreter makes the target unambiguous:

python -m pip install --upgrade pip
python -m pip install -r requirements.txt

The first command is optional. The second reads dependency names and version constraints from requirements.txt. If your project does not have that file, install the packages it documents individually, still using python -m pip or the activated environment’s pip.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

Do not use sudo pip for application packages in this workflow. Running pip with sudo targets a system location and can mix project dependencies with the operating system’s Python files. The virtual environment is intended to let the project account install its own packages without changing that global installation.

Step 6: leave and re-enter the environment

When you finish work in the current shell, run:

deactivate

The prompt loses its environment prefix and the shell returns to its previous command paths. Deactivation does not delete files or uninstall packages.

To work on the project again in a new shell, return to its directory and activate the existing environment:

cd ~/projects/myproject
source .venv/bin/activate

Activation is a per-shell operation. A new SSH session, a new terminal tab, or a separately launched script does not inherit it automatically, so scripts should call the environment’s interpreter by its path or activate it in the script’s own shell.

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

Creation options you may need

Python’s venv module provides several options. The available flags can vary by Python release; the following are documented in the Python 3.10 usage text.

Option Example Effect
--upgrade python3 -m venv --upgrade .venv Updates an existing environment to the Python installation used for the command.
--without-pip python3 -m venv --without-pip .venv Creates the environment without bootstrapping pip through ensurepip.
--prompt PROMPT python3 -m venv --prompt appenv .venv Uses the supplied text in the activated shell prompt instead of deriving it from the directory name.
--upgrade-deps python3 -m venv --upgrade-deps .venv Requests an upgrade of core packaging dependencies during creation. This is a venv option, not an ensurepip option.
--system-site-packages python3 -m venv --system-site-packages .venv Allows the environment to see packages installed system-wide.

Use --system-site-packages only when you deliberately need access to global packages. It reduces separation between the project and the operating system’s Python environment, so ordinary application environments are usually clearer without it.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting common VPS errors

No module named venv

This usually means the Ubuntu or Debian venv package is missing. Install it and repeat creation:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
sudo apt update
sudo apt install python3-venv
python3 -m venv .venv

If you invoked a versioned interpreter, install that interpreter’s matching venv package when available, then run the versioned command again.

ensurepip is not available

Environment creation normally bootstraps pip through Python’s ensurepip component unless --without-pip is supplied. This error indicates that the Python build does not provide ensurepip. On Ubuntu, install the package matching the interpreter version, such as python3.X-venv, and recreate the environment.

For example, determine the version first:

python3 --version

Then install the corresponding venv package exposed by your Ubuntu release. If the existing directory was created only partially, remove that directory after confirming it contains no application data and run the creation command again.

The wrong Python version appears after activation

Activation does not select a new base interpreter; it exposes the interpreter already recorded when the environment was created. Check both values:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
python3 --version
source .venv/bin/activate
python --version
python -c "import sys; print(sys.executable)"
cat .venv/pyvenv.cfg

If the version is not the one your application requires, deactivate, remove the disposable environment directory, and recreate it with the intended executable, for example python3.11 -m venv .venv. Reinstall dependencies afterward.

source fails or the activation file is missing

Check that you are in the directory containing .venv and that creation completed:

pwd
ls -la .venv
ls -la .venv/bin/activate

If .venv is absent or incomplete, correct the package or permission problem and recreate it. The Linux activation path is .venv/bin/activate; Windows uses a different layout and is outside this VPS procedure.

Permission denied while creating or installing

Create the environment in a directory your account owns, such as ~/projects/myproject. Avoid repairing a project environment with sudo, because that can leave files owned by root and prevent the application account from updating them. If an administrator created the directory, have its ownership and permissions corrected before retrying.

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

Keeping environments predictable on a server

Use one environment per application

Place each application’s environment at a clear path and activate it only when working on that application. This prevents one project’s package changes from silently affecting another project’s imports.

Make the interpreter explicit in scripts

Interactive activation is convenient for an administrator, but a scheduled job or service may start without your interactive shell setup. Point such tooling at the environment’s interpreter directly, for example:

/home/your-user/projects/myproject/.venv/bin/python -m your_module

Replace the path and module with your application’s actual values. The important property is that the command names the environment’s interpreter rather than relying on whichever python happens to be first on a service’s PATH.

Recreate rather than hand-edit a broken environment

The environment contains generated metadata and links to its base interpreter. If the base Python installation is removed, moved, or changed incompatibly, recreating .venv is generally less error-prone than manually editing its files. Preserve your dependency specification, remove only the environment directory, create it with the intended interpreter, and reinstall the requirements.

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

A repeatable command checklist

  1. Confirm the interpreter: python3 --version.
  2. Install the Ubuntu/Debian module: sudo apt install python3-venv, or the matching versioned package.
  3. Enter the application directory: cd ~/projects/myproject.
  4. Create the environment: python3 -m venv .venv.
  5. Activate it: source .venv/bin/activate.
  6. Verify paths with command -v python and python -c "import sys; print(sys.executable)".
  7. Install dependencies with python -m pip install -r requirements.txt.
  8. When finished, run deactivate.

That sequence gives the project its own Python package context while leaving the VPS’s system Python installation separate. For exact flags, consult the documentation for the Python version actually installed on the server.

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.

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 from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair 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.