Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › Django

How to Run Projects with Different Django Versions Using virtualenv

By Freedom251 Team · · 11 min read

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.

Use one virtual environment per Django project, create each environment with the Python interpreter that project supports, and install Django with an explicit version pin. Activating a project’s environment makes its python, pip, django-admin and manage.py commands use the correct dependency set without changing another project.

The isolation model: one project, one environment

A virtual environment is a directory containing an isolated Python installation context and its site-packages. Django installed there is available to that environment, not to every project on the computer. This is what lets an older application continue using its tested Django release while a newer application uses a different one.

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.

Keep the environment inside, or immediately beside, its project directory. A typical layout is:

inventory-site/
├── .venv-django42/
├── manage.py
├── requirements.txt
└── inventory/

billing-site/
├── .venv-django51/
├── manage.py
├── requirements.txt
└── billing/

Only one environment needs to be active in a shell at a time. Deactivate the current one before activating another, or open a separate terminal for each project. Installing Django in one environment does not replace the installation in the other.

#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.

Check Python and Django compatibility before creating anything

The Python executable selected at environment creation is as important as the Django version. Django and its third-party packages publish supported-Python ranges; a release that works on Python 3.11 may not install or run on an older interpreter. Check the project’s deployment documentation, dependency files and Django release notes, then map each project to a compatible interpreter.

Project need What to determine Why it matters
Existing application The Django version currently required, including any patch-series constraint such as 4.2.* Unpinned installation can silently select a release whose APIs or security behavior differ from the application’s tested version.
Python runtime The exact executable available on the machine, for example Python 3.11 The interpreter determines which Django releases and compiled dependencies can be installed.
Project dependencies requirements.txt, a constraints file, or the project’s declared package metadata Django alone is rarely sufficient; database drivers, form libraries and deployment packages must match it.
Operating system Shell and activation syntax used by the team Activation commands differ between Unix-like shells and Windows PowerShell.

Do not infer a current release from an old tutorial. The Django download page has shown python -m pip install Django==6.1.2 as a version-pinned example and recommends reading documentation that matches the installed version. Treat 6.1.2 as that page’s example, not as a promise that it is the current release when you run the command.

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.

Create a virtual environment with the project’s Python interpreter

Unix-like systems (Linux and macOS)

From the project directory, call the interpreter you intend to use. The python3.11 name is only an example; replace it with the executable installed on your machine.

python3.11 -m venv .venv-django42
source .venv-django42/bin/activate

The first command creates an environment named .venv-django42. The second changes the current shell so that python and pip resolve inside it. A prompt such as (.venv-django42) normally appears, but verify with commands rather than relying only on the prompt.

If the project specifically uses the third-party virtualenv command, the equivalent interpreter selection is:

python3.11 -m virtualenv .venv-django42
source .venv-django42/bin/activate

Python’s built-in venv and the virtualenv package both create isolated environments. Use the one supported by your project tooling; the crucial detail is invoking it with the correct Python executable.

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

Windows PowerShell

py -3.11 -m venv .venv-django42
.venv-django42ScriptsActivate.ps1

Here, py -3.11 asks the Windows Python launcher for Python 3.11. If PowerShell blocks the activation script because of its execution policy, follow your organization’s policy for allowing locally created scripts or activate the environment from a permitted shell. Do not work around a managed security policy without authorization.

With third-party virtualenv installed, use:

py -3.11 -m virtualenv .venv-django42
.venv-django42ScriptsActivate.ps1

Install the exact Django release and the rest of the project dependencies

Upgrade packaging tools inside the newly activated environment, then install Django with a constraint that expresses the project’s requirement. The following example keeps the project on the Django 4.2 patch series:

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.
python -m pip install --upgrade pip
python -m pip install "Django==4.2.*"
python -m pip install -r requirements.txt
python -m django --version

Using python -m pip ties pip to the active interpreter. It prevents a common error in which a system-wide pip installs Django successfully but the project’s Python cannot import it. Install the project’s remaining dependencies after Django, unless the requirements file already pins Django; in that case, keep one authoritative constraint and avoid contradictory declarations.

On Windows PowerShell, the same sequence can be run after activation:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
py -m pip install --upgrade pip
py -m pip install "Django==4.2.*"
py -m pip install -r requirements.txt
py -m django --version

The Windows launcher’s py -m pip command uses the interpreter selected for the active environment when activation has modified the shell. If there is any doubt, use the environment’s absolute executable path (for example, .venv-django42Scriptspython.exe -m pip) to remove ambiguity.

A fully pinned application may instead require one exact release:

python -m pip install "Django==4.2.16"

Use the exact version recorded by the application’s dependency specification. A wildcard such as 4.2.* allows newer patch releases in that series; an exact value is more reproducible when the project has been validated against one patch release.

Verify that every command is using the intended environment

Run these checks immediately after activation and whenever a project appears to use the wrong Django version:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
python --version
python -c "import sys; print(sys.executable)"
python -m pip --version
python -m django --version

The executable path should point into the project’s environment directory, and the pip path should show the same environment. The Django version printed by python -m django --version is the version imported by that interpreter.

You can also inspect where command-line entry points resolve:

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
# macOS/Linux
which python
which pip
which django-admin

# Windows PowerShell
Get-Command python
Get-Command pip
Get-Command django-admin

If django-admin resolves outside the environment, use python -m django or reactivate the environment. The project’s manage.py is even safer: it is a Python script, so invoke it as python manage.py after confirming python points to the right environment.

Run each project without cross-contamination

Starting a development server

Activate the environment belonging to the project, change to the directory containing its manage.py, and run:

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

All imports made by that process come from the active environment. Open a second terminal, activate the other project’s environment, and run its server on a different port if both need to run simultaneously:

python manage.py runserver 8001

Running administrative commands

Use the same activation discipline for migrations, tests, shell sessions and static-file collection:

python manage.py migrate
python manage.py test
python manage.py shell
python manage.py collectstatic

These commands load the project settings and dependencies selected by that project’s Python interpreter. Never run a migration against a production database until the environment and settings have been checked; a wrong Django version can alter migration behavior or fail before the command starts.

Keep multiple Django projects side by side

Project Environment Django constraint Activation (Unix-like) Activation (PowerShell)
Legacy application .venv-django42 Django==4.2.* or the project’s exact pin source .venv-django42/bin/activate .venv-django42ScriptsActivate.ps1
New application .venv-django51 The release required by its dependency specification source .venv-django51/bin/activate .venv-django51ScriptsActivate.ps1
Upgrade test copy .venv-django-target The proposed target release source .venv-django-target/bin/activate .venv-django-targetScriptsActivate.ps1

The environment directory name is a convenience, not a technical requirement. Names that include the Django series make mistakes easier to spot, while a simple .venv is convenient when each repository has only one supported version. Do not commit the environment directory itself to version control; commit the files that describe how to recreate it.

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

Switch versions safely

Switching between existing projects

Stop running development processes, leave the current shell environment, then activate the other one:

deactivate
cd ../other-project
source .venv-django51/bin/activate
python -m django --version

On PowerShell, deactivate is also available after activation. Closing the terminal is an alternative that guarantees no old activation remains.

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.

Changing Django in the same environment

An in-place change is quick but can leave incompatible packages behind. If you choose it, record the current dependency state first:

python -m pip freeze > requirements-before-upgrade.txt
python -m pip install --upgrade "Django==TARGET.VERSION"
python manage.py check
python manage.py test

Replace TARGET.VERSION with a real version required by the project. Review the resolver’s output and run the full test suite, system checks and representative management commands. An in-place upgrade is reasonable for a small, well-tested change; it is risky when several packages have coupled version requirements.

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

Building a fresh environment for a major upgrade

Django’s upgrade guidance notes that, when using a virtual environment, you might want to set up a new environment with all dependencies first. This preserves the old environment as a rollback point and separates installation problems from application changes.

  1. Commit the current code and dependency files, and export the working environment if the project does not already have a complete specification.
  2. Create a new environment with a Python interpreter supported by the target Django release: python3.11 -m venv .venv-django-target or py -3.11 -m venv .venv-django-target.
  3. Activate the new environment and upgrade pip inside it.
  4. Install the target Django version and the project’s complete dependency set. Update constraints where the target release requires newer packages.
  5. Run python manage.py check, the automated tests, migration checks and any application-specific smoke tests.
  6. Exercise authentication, administration, database writes, background jobs, email and static-file handling—the areas most likely to expose dependency or framework changes.
  7. Switch local tooling, service definitions or deployment configuration to the new environment only after it is healthy.
  8. Keep the old environment until the new release has passed the acceptance and rollback window; remove it only when the team no longer needs the fallback.
Approach Rollback safety Dependency-conflict risk Testing effort Best fit
In-place upgrade Lower; the previous package set is overwritten unless separately exported Higher when many packages are coupled Must be done before and after changing packages Small, well-tested updates with a quick recovery plan
Fresh environment Higher; the old environment remains intact Lower visibility of stale packages because installation starts clean Requires installing and validating the full dependency set Major Django upgrades, legacy applications and production changes
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Make environments reproducible

Virtual environments are disposable. The project’s dependency declarations are the durable record. Keep them in version control and rebuild a new environment from those files rather than copying an old environment directory between machines.

  • Use a requirements or constraints file that records Django and compatible third-party versions.
  • After a deliberate dependency change, review the resolver output and update the file in the same commit as the code change.
  • Use python -m pip freeze when you need a complete snapshot of an already working environment, but review generated entries before treating that snapshot as the project’s intended specification.
  • Document the required Python interpreter, activation command and verification command in the project’s setup instructions.
  • Recreate the environment on a second machine or in continuous integration to detect undeclared dependencies.

A clean rebuild should follow the same sequence every time: select Python, create the environment, activate it, upgrade packaging tools, install pinned dependencies, run checks and tests, then start the application.

venv or virtualenv: which should you use?

Consideration venv virtualenv
Availability Included with supported Python installations; some minimal distributions require adding the matching venv package. Requires installing the virtualenv package first.
Interpreter selection Use the desired interpreter explicitly, such as python3.11 -m venv or py -3.11 -m venv. By default it uses the interpreter that runs it and can discover an explicitly selected interpreter through standard mechanisms.
Speed and convenience Simple and sufficient for most Django repositories. Often offers additional environment-management features and can be faster in some workflows.
Tooling compatibility Works with standard pip, Django and common editor integrations. Use when the project or team tooling specifically depends on it.
Recreation Recreated from the same Python version and dependency pins. Recreated from the same Python version and dependency pins.

Neither tool allows two Django versions to be active in one environment. The isolation boundary is the environment directory, regardless of whether it was created by venv or virtualenv.

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

Troubleshoot the failures that cause most version mix-ups

“Django is installed” but import or version checks fail

Compare python -c "import sys; print(sys.executable)" with python -m pip --version. If either path is outside the project environment, activate it again and install with python -m pip. Avoid bare pip until the paths are confirmed.

django-admin reports the wrong version

The shell is resolving a global entry point. Check which django-admin or Get-Command django-admin, then use python -m django and python manage.py from the activated environment. Restarting the shell also clears stale command paths.

The requested Django release will not install

Verify the selected Python version against that Django release’s supported range, then inspect the resolver’s first conflict. A package with compiled components may also lack a wheel for your operating system and Python version. Choose a compatible interpreter or update the dependency set deliberately; do not bypass the conflict by mixing global and environment packages.

PowerShell refuses to activate

The activation script is being blocked by execution-policy settings. Use the organization-approved policy or an approved shell, and ensure you are running the script from the project directory. The environment itself is not damaged merely because activation was denied; you can still invoke its Python executable by absolute path.

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

A new terminal loses the environment

Activation applies to one shell process. Activate the environment in every new terminal, editor-integrated terminal and deployment session. Add the activation command to documented setup steps rather than assuming it persists across sessions.

The project works locally but fails in deployment

Compare the deployment Python version and dependency installation with the local specification. Rebuild the environment from committed pins, run python manage.py check and the test suite in the deployment process, and confirm that the service starts with the intended environment’s absolute Python path.

Use the same discipline in editors, CI and deployment

Configure your editor or IDE to use the project’s environment interpreter, not a system interpreter. Select the executable inside .venv-django42 for the legacy project and the executable inside the other project’s environment for the newer one. Integrated test runners and language servers then import the same Django version as the terminal.

Continuous-integration jobs should create a fresh environment for each run, install the pinned dependencies, print the Python and Django versions, and execute checks and tests. Deployment services should likewise point directly to the environment’s Python executable or activate it in the service command. This avoids relying on whichever global Django happens to be installed on the host.

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

When a project is upgraded, deploy the new environment as a separate artifact or directory, run its checks, and retain the previous environment long enough to make a controlled rollback. The old environment is useful only if its dependency files, code revision and configuration are also preserved.

A repeatable checklist

  • Identify the Django and Python versions required by each project.
  • Create a separate environment with the matching Python interpreter.
  • Activate it before installing packages or running project commands.
  • Install Django with an explicit version constraint and install all remaining pinned dependencies.
  • Verify sys.executable, pip’s path and python -m django --version.
  • Run management commands as python manage.py ... from the project directory.
  • For major upgrades, build a fresh environment, test it, and keep the old one for rollback.
  • Commit dependency specifications, not the environment directory.

Following this pattern lets one computer host projects on different Django releases without replacing packages behind each other. The selected Python interpreter, isolated environment and explicit dependency pins together determine which framework each project runs.

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.

DjangoPythonPython environmentsvenvvirtualenvWeb development

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.

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

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.