Creating and Managing Python Virtual Environments and Running a Django Project

Python Virtual Environments provide an isolated workspace for managing dependencies, Python versions, and frameworks such as Django. By using virtual environments, developers can avoid conflicts between packages and run multiple projects with different configurations. This article explains how to create virtual environments with specific Python versions, activate them, update pip, install Django (latest or specific versions), and finally run a Django project using the development server.

Python Virtual EnvironmentDjango installationpip management

~2 min read • Updated Feb 4, 2026

1. What Is a Python Virtual Environment?


A Virtual Environment is an isolated environment that allows a Python project to have its own dependencies, libraries, and Python version without affecting other projects or the system-wide installation.


This approach helps prevent version conflicts and ensures project stability.


2. Creating a Virtual Environment with a Specific Python Version


You can create virtual environments using different installed Python versions.


py -3.14 -m venv myenv

The command above creates a virtual environment named myenv using Python 3.14.


py -3.13 -m venv oldenv

This command creates another environment using Python 3.13.


3. Activating the Virtual Environment on Windows


After creating the environment, it must be activated.


C:\Users\python\Desktop\myenv\Scripts>activate

Once activated, the environment name appears at the beginning of the terminal:


(myenv) C:\Users\python\Desktop\myenv\Scripts>

4. Checking Python and pip Versions


To check the active Python version:


py -V

To check the installed pip version:


pip -V

5. Updating pip to the Latest Version


To upgrade pip inside the virtual environment:


python -m pip install --upgrade pip

6. Listing Installed Packages


To view all installed packages in the environment:


pip list

To export installed packages to a file:


pip freeze > package.txt

This file can be used to recreate the environment on another system.


7. Installing Django in the Virtual Environment


To install the latest version of Django:


pip install django

To install a specific version of Django:


pip install django==5.0.3

Verify the installed Django version:


django-admin --version

8. Creating a Django Project


To create a new Django project:


django-admin startproject myproject

Navigate into the project directory:


cd myproject

9. Running the Django Development Server


To start the Django development server:


python manage.py runserver

The project will be available at the following address:


http://127.0.0.1:8000/

Conclusion


Using a Python Virtual Environment allows developers to safely manage dependencies, Python versions, and frameworks such as Django. This workflow is essential for building scalable, portable, and professional Python projects.


Written & researched by Dr. Shahin Siami