Python----Django Installation

Source: Internet
Author: User

Django installation, Environment preparation:

1. Python installation package and installation

2. Django installation Package

Python Package Installation 1.Linux installation

If you are using a Linux system or Mac OS X, the system may already have Python preinstalled. Enter Python in the Terminal Command Line window (or in the Program/tool/terminal of OS X). If you see this information, Python is already installed.

Python 2.7.10 (#2, Mar 31 2005, 00:05:10)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on Darwin
Type "Help", "copyright", "credits" or "license" for more information.
>>>
2.Windows under Installation

First, download the latest version of 2.7.9 from the official website of Python, www.python.org the following address: Http://www.python.org/ftp/python/2.7.9/python-2.7.9.msi

Then, run the downloaded MSI installation package, and tick all the components when you select the step of the installation component:

Pay attention to the selection pip and Add python.exe to Path (with this you do not have to manually configure the environment variable), and then all the way to "Next" to complete the installation.

Python will be installed by default in the C:\Python27 directory, and then open a command prompt (cmd) window, after entering Python, there are two scenarios:

Case one: As shown, Python is installed properly, can be used, type any Python code, enter to execute, and get the results. You can enter exit() and return to exit the Python interactive environment (of course, the direct k out of the command line window more convenient).

Situation two: Get an error:显示

This is because Windows will look for the Path path set by an environment variable, and if it does python.exe 解释器 not, it will report the error shown. If you omit the tick during installation, you will Add python.exe to Path need to manually python.exe add the path C:\Python27 to the environment variable path. If you don't know how to modify the environment variable, you can also reinstall the Python installer again, remember to check it Add python.exe to Path 就可以了 .

Django installation 1. Environment preparation

Os:ubuntu 13.04 64bits/centos

python:2.7.4 is just the version number, and you can install the Python version yourself as needed

django:1.9.5 is just the version number, and you can install the Django version yourself as needed

2. Download and install Django

The official release version comes with a version number, such as 1.0.3 or 1.1, and the latest version can be obtained at http://www.djangoproject.com/download/, as shown in the download location.

in the Linux and the Windows installed on Django The difference is not small. Install the Linux installation First:

1. Unzip the package

Tar xvzf t django-*.tar.gz

2. Go to the Uncompressed Tornado folder

CD django-*

3, Tornado installation (need to install with the super User, or will be reported insufficient authority)
sudo python setup.py install

Linux under the Django installation is complete. installation under Windows is similar to Linux .

1. Unzip the package

2. Locate the Unpacked folder under "Command Prompt"

3, Tornado installation

Python setup.py Install

In this way, Django is installed and installed in a Python-related library path, such as: C:\Python27\Lib\site-packages\Django-1.9.5-py2.7.egg Of course, the dependent files are appended to the Python-related library, respectively.

Note: You will need to set the Django installation path to the PATH environment variable after the installation is complete under Windows. Procedure to increase the Python environment variable practice, copy the Django installation path, such as C:\Python27\Lib\site-packages\Django-1.9.5-py2.7.egg\django\bin paste into the path variable value; The Linux system does not need to set environment variables.

3. Verify

Linux System: Open terminal, enter Python into Python interactive mode, enter Importdjango carriage return, and then enter Django. Version returns to see the Django versions, indicating that the installation is complete and you can use

Under WINdows : cmd Open a command prompt, enter the python instruction into Python interactive mode, enter Importdjango carriage return, and then enter Django. Version returns to see the Django versions, indicating that the installation is complete and ready to use.

4. Project Establishment

Under Linux system:

1. Create a new directory first: mkdir test

2. Enter the new folder TEST:CD test

3. New project: django-admin.py startproject test1

After the command is executed, a new test1 directory can be seen in the test directory, and a Test1 project containing a test1 directory and a manage.py file can be seen into the Test1 directory. The Test1 directory contains __init__.py,settings.py,urls.py,wsgi.py, as shown in 1.

Of course, you can also create a new project with the tool Pycharm tool, Pycharm is a python-developed custom tool (Pycharm is a Python IDE with a set of tools to help users improve their efficiency when developing with the Python language, such as debugging, syntax highlighting, Project management, code jumps, smart tips, AutoComplete, unit tests, version control. In addition, the IDE provides advanced features to support professional web development under the Django framework. ), as shown in Figure 3, 2, choose Django when you are new.

Figure 1

Figure 2

Figure 3, the two installation mode files are the same

WINDIWS System: A new Django project under Windows is the same as under Linux, except that one is the command prompt used and the other is the Linux terminal.

1. New folder: MkDir test1

2. Go to Folder TEST1:CD test1

3. Execute create command: django-admin.py startproject test2
Note: If you do not set the Django installation path to the PATH environment variable after the Django installation is completed in the Windows system, you will get an error, as shown in.

The Django environment variable is set up correctly and the project is set up correctly, and the Django project is built, as shown in the following three figures:

         Windows PYCHRM build Project and Linux under the same, no difference.

Python----Django Installation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.