AI教程网 - 未来以来,拥抱AI;新手入门,从AI教程网开始......


Django2.0手册 AI君 134℃

This document will guide you through installing Python 3.5 and Django on
Windows. It also provides instructions for installing virtualenv and
virtualenvwrapper, which make it easier to work on Python projects. This is
meant as a beginner’s guide for users working on Django projects and does not
reflect how Django should be installed when developing patches for Django

The steps in this guide have been tested with Windows 7, 8, and 10. In other
versions, the steps would be similar. You will need to be familiar with using
the Windows command prompt.


Django 是一个 Python Web 框架,因此需要在您的机器上安装 Python。在本文撰写时,Python 最新的版本是 3.5。

To install Python on your machine go to The
website should offer you a download button for the latest Python version.
Download the executable installer and run it. Check the box next to Add
Python 3.5 to PATH
and then click Install Now.

After installation, open the command prompt and check that the Python version
matches the version you installed by executing:

python --version

关于 pip¶

pip is a package manage for Python. It makes installing and uninstalling
Python packages (such as Django!) very easy. For the rest of the installation,
we’ll use pip to install Python packages from the command line.

想要在您的机器上安装 pip,请转至,并按照“Installing with”说明进行操作

安装 virtualenv 和 virtualenvwrapper¶

virtualenv and virtualenvwrapper provide a dedicated environment for
each Django project you create. While not mandatory, this is considered a best
practice and will save you time in the future when you’re ready to deploy your
project. Simply type:

pip install virtualenvwrapper-win


mkvirtualenv myproject

The virtual environment will be activated automatically and you’ll see
“(myproject)” next to the command prompt to designate that. If you start a new
command prompt, you’ll need to activate the environment again using:

workon myproject



In the command prompt, ensure your virtual environment is active, and execute
the following command:

pip install django


After the installation has completed, you can verify your Django installation
by executing django-admin --version in the command prompt.

See Get your database running for information on database installation
with Django.

Common pitfalls¶

  • If django-admin only displays the help text no matter what arguments
    it is given, there is probably a problem with the file association in
    Windows. Check if there is more than one environment variable set for
    running Python scripts in PATH. This usually occurs when there is more
    than one Python version installed.

  • If you are connecting to the internet behind a proxy, there might be problem
    in running the command pip install django. Set the environment variables
    for proxy configuration in the command prompt as follows:

    set http_proxy=http://username:password@proxyserver:proxyport
    set https_proxy=https://username:password@proxyserver:proxyport

转载请注明 » Django2.0手册:如何在Windows上安装Django

喜欢 (0)or分享 (0)