您所在的位置:小祥子 » 编程 » Python » 正文

安装 Django

时间:2015-08-11 编辑:小麦粉 来源:CnBlogs

refrence: https://docs.djangoproject.com/en/1.8/intro/install/

安装 Django

三种可选的方式进行安装 Django:

  • 通过操作系统的提供的 Django 分发包进行安装
    $sudo apt-get install python-django
  • 安装官方发布的版本, 这种安装方式通常是极好的
    • 使用 pip 工具 (pip (package manager) for python)
      $pip install django # lastest version
      $pip install 'django==1.4' # specific version
      $pip install 'django<=1.4' # maximum version
      $pip install 'django>=1.4' # minimum version
    • 手动安装
    1. 下载安装包 download page.
    2. 解压并执行安装指令
      $python setup.py install
  • 安装开发版本
    $ git clone git://github.com/django/django.git django-trunk

验证安装

$python -c 'import django; print(django.get_version())'
1.4.5

完整案例:

cc@debian:~$ mkdir py-env-dj-1.8
cc@debian:~$ virtualenv py-env-dj-1.8/
New python executable in py-env-dj-1.8/bin/python
Installing setuptools, pip, wheel...done.
cc@debian:~$ . py-env-dj-1.8/bin/activate
(py-env-dj-1.8)cc@debian:~$ pip install 'django>=1.8'
/home/cc/py-env-dj-1.8/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
Collecting django>=1.8
  Downloading http://pypi.douban.com/packages/py2.py3/D/Django/Django-1.8.3-py2.py3-none-any.whl (6.2MB)
    46% |██████████████▉                 | 2.9MB 151kB/s eta 0:00:22
关键词:安装

相关文章