Installing Python and Django - potatoscript/django GitHub Wiki
π§° What You Need Before Starting
π¦ Tool | β Required |
---|---|
π Python 3 | Yes! |
π» A Terminal (Command Prompt / Terminal app) | Yes! |
π§ Curiosity & patience | Absolutely yes! |
π Step 1: Install Python (for Windows, macOS, Linux)
πΉ For Windows
-
π Go to https://www.python.org/downloads/
-
Click the big yellow button that says
Download Python 3.x.x
-
VERY IMPORTANT: β Check the box βAdd Python to PATHβ before clicking Install Now
-
Wait until it finishes. Then open Command Prompt (CMD) and type:
python --version
β You should see something like:
Python 3.12.1
π You did it!
π For macOS
- macOS often comes with Python installed, but itβs usually Python 2.
- So, open Terminal and install Homebrew (if you donβt have it):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Then install Python:
brew install python
- Check the version:
python3 --version
π Done!
π§ For Linux (Ubuntu/Debian)
Open your Terminal and run:
sudo apt update
sudo apt install python3 python3-pip
Check:
python3 --version
π Ready to roll!
π§ͺ Step 2: Create a Virtual Environment
A virtual environment is like a sandbox just for your project.
It keeps your project clean and tidy π§Ό
- In your Terminal, make a new folder:
mkdir django_app
cd django_app
- Create the virtual environment:
python -m venv env
- Activate the virtual environment:
- πͺ Windows:
env\Scripts\activate
- π Mac/Linux:
source env/bin/activate
β¨ If it works, your terminal prompt will show:
(env) your-folder-name $
π‘ Donβt forget to activate your environment every time before coding Django.
π¦ Step 3: Install Django
While inside your virtual environment, run:
pip install django
β To confirm Django installed:
django-admin --version
Output:
5.0.3
π You just installed Django!
π Bonus: Freeze Your Requirements (Optional but Professional)
Letβs record the installed packages so others can copy your setup:
pip freeze > requirements.txt
Later, you (or your team) can run:
pip install -r requirements.txt
π₯ Very pro move!