Django Installation
Before installing Django, the system needs to have the Python development environment already installed.
If you have not installed Python yet, first download and install the latest version of Python from the official Python website https://www.python.org/ download and install the latest version of Python.
Installing Django is also simple; just use the package management tool pip:
pip install Django
After installation, you can verify that Django was installed successfully by running the following command:
python3 -m django --version
If all goes well, you will see the installed Django version number, such as: 4.2.7.
Recommended development environments:
Installing Django on Windows
Next, let's take a detailed look at installing Django on different systems.
If you have not installed the Python environment yet, you need to first download the Python installation package.
1. Python download address:https://www.python.org/downloads/
2. Django download address:https://www.djangoproject.com/download/
**Note:** Currently, Django version 1.6.x and above are fully compatible with Python 3.x.
Python installation (skip if already installed)
To install Python, you only need to download the python-x.x.x.msi file and then keep clicking the "Next" button.
After installation, you need to set the Python environment variables. Right-click Computer -> Properties -> Advanced -> Environment Variables -> modify the system variable path and add the Python installation address; this article's example uses C:\Python33, but you need to install according to your actual situation.

Django Installation
Download the Django compressed package, extract it and place it in the same root directory as the Python installation directory, enter the Django directory, run python setup.py install, and then installation begins; Django will be installed into site-packages under Python's Lib.

Then configure the environment variables by adding these directories to the system environment variables: C:\Python33\Lib\site-packages\django;C:\Python33\Scripts. Once added, you can use Django's django-admin.py command to create a new project.
Check whether installation was successful
Enter the following command to check:
>>> import django
>>> django.get_version()

If the Django version number is output, the installation is correct.
Installing Django on Linux
yum installation method
The following installation is performed in a Centos Linux environment; if your Linux system is ubuntu, please use the apt-get command.
By default, the Linux environment already supports Python. You can enter the Python command in the terminal to check whether it is installed.
Python 3.7.4 (default, Aug 1 2012, 05:14:39)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
Install setuptools
Command:
# Python3 Installation
yum install python3-setuptools
# Python2 Installation
yum install python2-setuptools
Once done, you can use the easy_install command to install django
easy_install django
Then we enter the following code in the Python interpreter:
[root@solar django]# python
Python 3.7.4 (default, May 15 2014, 14:49:08)
[GCC 4.8.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.VERSION
(3, 0, 6, 'final', 0)
We can see the Django version number output, indicating a successful installation.
pip command installation method
If you have not installed the pip tool yet, you can check:Python pip Installation and Usage。
sudo pip3 install Django -i https://pypi.tuna.tsinghua.edu.cn/simple
-i https://pypi.tuna.tsinghua.edu.cn/simple specifies the Tsinghua mirror source for faster downloads.
Specify the Django download version (3.0.6 can be changed to the version you want):
sudo pip3 install Django==3.0.6 -i https://pypi.tuna.tsinghua.edu.cn/simple
If pip < 1.4, the installation method is as follows:
pip install https://www.djangoproject.com/download/1.11a1/tarball/
Source code installation method
Download the source package:https://www.djangoproject.com/download/
Enter the following command and install:
tar xzvf Django-X.Y.tar.gz # 解压下载包
cd Django-X.Y # 进入 Django 目录
python setup.py install # 执行安装命令
After successful installation, Django is located in the site-packages directory of the Python installation directory.
Installation on Mac
Download
From theHereDownload the latest stable version: DJango-3.x.y.tar.gz, download it from the list on the right side of the page, as shown below:

Remember to use the latest official version. Among them x.y is the version number. Enter the folder directory where you downloaded the file and run the following command: (on Mac the default is /Users/xxx/Downloads, where xxx is your username)
$ tar zxvf Django-3.x.y.tar.gz
You can also download the latest version from Github, at:https://github.com/django/django:
git clone https://github.com/django/django.git
Installation
Enter the extracted directory:
cd Django-3.x.y
sudo python setup.py install
After successful installation, the following information is output:
……
Processing dependencies for Django==3.x.y
Finished processing dependencies for Django==3.x.y
Then enter our site directory and create a Django project:
$ django-admin.py startproject testdj
Start the service:
cd testdj # 切换到我们创建的项目
$ python manage.py runserver
……
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
The above information indicates that the project has started and the access address is http://127.0.0.1:8000/.