Django installation

Before installing Django, the system requires a development environment where Python is already installed. Next, let's take a closer look at the installation of Django under different systems.

Install Django under Window

If you haven't installed the Python environment yet, you need to download the Python installation package first.

1, Python Download: https://www.python.org/downloads/< /p>

2, Django Download: https://www.djangoproject.com/download/< /p>

Note: Currently Django 1.6.x and above is fully compatible with Python 3.x.

Python installation (installed skippable)

To install Python you only need to download the python-x.x.x.msi file and then click the "Next" button.


You need to set the Python environment variable after the installation is complete. Right-click on the computer -> Properties -> Advanced -> Environment Variables -> Modify the system variable path, add the Python installation address, this example uses C:\Python33, you need to install according to your actual situation.


Django installation

Download the Django tarball, unzip it and place it in the same root directory as the Python installation directory, go into the Django directory, execute python setup.py install, and start the installation. Django will be installed into Python's Lib site-packages.


Then configure the environment variables and add these directories to the system environment variables: C:\Python33\Lib\site-packages\django;C:\Python33\Scripts. Once the addition is complete, you can use Django's django-admin.py command to create a new project.


Check if the installation is successful

Enter the following command to check:

>>> import django
>>> django.get_version()

If the Django version number is output, the installation is correct.

Install Django on Linux

yum installation method

The following installation is installed under the Centos Linux environment. If your Linux system is ubuntu, please use the apt-get command.

The Linux environment already supports Python by default. You can check if it is installed by entering the Python command in the terminal.

Python 2.7.3 (default, Aug< /span> 1 2012< /span>, 05: 14:39)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or< Span class="pln"> "license" for more information.

Install setuptools


yum install python-setuptools 

Once you're done, you can install django with the easy_install command

easy_install django

After we enter the following code in the python interpreter:

[root@solar django ]# python
Python 2.7 .3 (default, May 15 2014, 14:49:08)
[GCC 4.8.0] on linux2
Type "help", "copyright", "credits" or< Span class="pln"> "license" for more information.
>>> import django
>>> django.VERSION
(1, 6, 5, 'final', 0)

We can see that the version number of Django is output, indicating that the installation was successful.

pip command installation method

pip install Django

If pip < 1.4, the installation method is as follows:

pip install https:/ /www.djangoproject.com/download/1.11a1/tarball/

Source installation method

Download the source package: https://www.djangoproject.com/download/

Enter the following command and install it:

tar xzvf Django-< /span>X.Y .tar.gz # Unzip the download package
Cd Django-X.Y # Enter the Django directory
Python setup.py install # Execute the installation command< /pre>

After the installation is successful, Django is located in the site-packages directory of the Python installation directory.

Install under Mac


Download the latest stable version from the here: DJango-1.xytar. Gz, download the list on the right side of the page, as shown below:

Remember to be the latest official version. x.y is the version number. Go to the folder where you downloaded the file and execute the following command: (default is /Users/xxx/Downloads on Mac, xxx is your username)

$ tar zxvf Django- 1.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


Go to the unzipped directory:

cd Django-1.x.y
Sudo python setup.py install

The following information will be output after successful installation:

Processing dependencies for Django==1.x.y
Finished processing dependencies for Django==1.x.y

Go into our site directory and create a Django project:

$ django-admin< /span>.py startproject testdj

Start the service:

cd testdj # Switch to the project we created
$ python manage.py runserver
Starting development server at
Quit the server with CONTROL-C.

The above information indicates that the project has been started and the access address is

welookups is optimized for learning.© welookups. 2018 - 2019 All Right Reserved and you agree to have read and accepted our term and condition.