7.3. Django installation

发布时间 :2025-10-25 12:24:14 UTC      

Before installing Django, the system needs a development environment that already has Python installed. Next, let’s take a specific look at the installation of Django on different systems.

7.3.1. Install Django under Windows

If you have not installed the Python environment, you need to download the Python installation package first.

1、Python 下载地址: https://www.python.org/downloads/

2、Django 下载地址: https://www.djangoproject.com/download/

注意: At present, Django 1.6.x and above are fully compatible with Python 3.x.

7.3.2. Python installation (installed can be skipped)

To install Python, you just need to download the python-x.x.x.msi file and click the “Next” button all the time.

image0

You need to set the Python environment variable after installation. Right-click 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.

image1

7.3.3. Django installation

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

image2

然后是配置环境变量,将这几个目录添加到系统环境变量中: C:Python33Libsite-packagesdjango;C:Python33Scripts。 添加完成后就可以使用Django的django-admin.py命令新建工程了。

image3

7.3.4. Check whether the installation is successful

Enter the following command to check:

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

image4

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

7.3.5. Install Django on Linux

7.3.6. Yum installation method

The following installation is located in the Centos Linux environment, if your Linux system is ubuntu, please use the apt-get command.

Python is already supported by the Linux environment by default. You can enter the Python command at the terminal to see if it has been 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.
>>>

7.3.7. Install setuptools

Command:

# Python3 安装
yum install python3-setuptools
# Python2 安装
yum install python2-setuptools

When you are finished, you can use the easy_install command to install django

easy_install django

Then we enter the following code into 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 that the version number of Django is output, indicating that the installation is successful.

7.3.8. Installation method of pip command

If you have not installed the pip tool, check out: Python pip 安装与使用 .

sudo pip3 install Django -i https://pypi.tuna.tsinghua.edu.cn/simple

-i https://pypi.tuna.tsinghua.edu.cn/simple Specify Tsinghua mirror source, download faster.

Specify the download version of Django (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/

7.3.9. 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 a successful installation, Django is located in the site-packages directory of the Python installation directory.

7.3.10. Install under Mac

7.3.11. download

From 这里 Download the latest stable version: DJango-3.x.y.tar.gz, and download it in the list on the right side of the page, as shown below:

image5

Remember, it’s the latest official version. Among them x.y It’s the version number. Enter the folder where you downloaded the file and execute the following command: (/ Users/xxx/Downloads,xxx is your user name by default under Mac)

$ 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

7.3.12. Installation

Enter the decompressed directory:

cd Django-3.x.y
sudo python setup.py install

The following information is output after a successful installation:

……
Processing dependencies for Django==3.x.y
Finished processing dependencies for Django==3.x.y

Then go to our site directory and create the 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 been started and the access address is http://127.0.0.1:8000/ .

Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.