← Back to Django Course | Chapter 1: Django Fundamentals & Setup | Lesson 5 of 9

Installing Django with pip

pip is the tool that fetches Django from the internet and puts it on your computer, kind of like an app store for Python code.

Upgrading pip First

Before installing packages it is good practice to upgrade pip itself, since an old pip version can fail to resolve newer package releases correctly.

Example: Upgrading pip First

Upgrades pip to its latest version before installing other packages.

bash
pip install --upgrade pip

⚠️ Run this command in your terminal.

Installing the Latest Django

Running "pip install django" with no version number always installs the newest stable release of Django available on PyPI.

Example: Installing the Latest Django

Installs the newest available version of Django.

bash
pip install django

⚠️ Run this command in your terminal.

Installing a Specific Django Version

Adding "==" followed by a version number, like "pip install django==5.0", installs that exact Django release instead of the newest one.

Note: Pinning versions keeps a project stable when a newer Django release changes behavior.

Example: Installing a Specific Django Version

Installs the exact Django version 5.0 instead of the latest release.

bash
pip install django==5.0

⚠️ Run this command in your terminal.

Saving Dependencies to a File

Running "pip freeze > requirements.txt" writes every installed package and its version into a file, so teammates can install the exact same setup later.

Example: Saving Dependencies to a File

Saves the currently installed packages and versions into a requirements.txt file.

bash
pip freeze > requirements.txt

⚠️ Run this command in your terminal.

Common Mistakes
  1. Running pip install without first activating the intended virtual environment.
  2. Using an outdated pip version, which can fail to install newer Django releases.
  3. Installing a specific Django version by typing the number wrong, e.g. "django==5..0".
Chapter Summary
  • pip is Python's standard package manager for installing libraries.
  • "pip install django" installs the latest stable Django release.
  • You can pin a specific version with "pip install django==5.0".
  • Installed packages can be saved to a requirements.txt file for sharing.

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.