{"title":"快速安装指南","version":"2.0","locale":"zh-hans","docname":"intro/install","url":"/zh-hans/2.0/intro/install/","canonical":"https://djangodocs.dev/zh-hans/2.0/intro/install/","summary":"开始用 Django 前，需要先进行安装。我们写了 complete installation guide 罗列了各种安装方法；它会指导你完成最小，快速安装。 安装 Python Link to this heading # 作为一个 Python Web 框架，Django 需要 Python。更多细节请参见…","html":"<h1>快速安装指南<a class=\"heading-anchor\" href=\"#quick-install-guide\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p>开始用 Django 前，需要先进行安装。我们写了 <a class=\"reference internal\" href=\"/zh-hans/2.0/topics/install/\"><span class=\"doc\">complete installation guide</span></a> 罗列了各种安装方法；它会指导你完成最小，快速安装。</p>\n<section id=\"install-python\">\n<h2>安装 Python<a class=\"heading-anchor\" href=\"#install-python\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>作为一个 Python Web 框架，Django 需要 Python。更多细节请参见 <a class=\"reference internal\" href=\"/zh-hans/2.0/faq/install/#faq-python-version-support\"><span class=\"std std-ref\">我应该使用哪个版本的Python来配合Django?</span></a>。Python 包含了一个名为 <a class=\"reference external\" href=\"https://sqlite.org/\">SQLite</a> 的轻量级数据库，所以你暂时不必自行设置一个数据库。</p>\n<p>最新版本的 Python 可以通过访问 <a class=\"reference external\" href=\"https://www.python.org/downloads/\">https://www.python.org/downloads/</a> 或者操作系统的包管理工具获取。</p>\n<p>你可以在你的 shell 中输入 <code class=\"docutils literal notranslate\"><span class=\"pre\">python</span></code> 来确定你是否安装过 Python；你看到的可能是像这样子的:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">Python</span> <span class=\"mf\">3.4</span><span class=\"o\">.</span><span class=\"n\">x</span>\n<span class=\"p\">[</span><span class=\"n\">GCC</span> <span class=\"mf\">4.</span><span class=\"n\">x</span><span class=\"p\">]</span> <span class=\"n\">on</span> <span class=\"n\">linux</span>\n<span class=\"n\">Type</span> <span class=\"s2\">&quot;help&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;copyright&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;credits&quot;</span> <span class=\"ow\">or</span> <span class=\"s2\">&quot;license&quot;</span> <span class=\"k\">for</span> <span class=\"n\">more</span> <span class=\"n\">information</span><span class=\"o\">.</span>\n<span class=\"o\">&gt;&gt;&gt;</span>\n</code></pre></div>\n</section>\n<section id=\"set-up-a-database\">\n<h2>设置数据库<a class=\"heading-anchor\" href=\"#set-up-a-database\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>此步骤仅在你打算使用诸如 PostgreSQL, MySQL, 或者 Oracle 这些大型数据库引擎时需要。要安装这种数据库, 请参考 <a class=\"reference internal\" href=\"/zh-hans/2.0/topics/install/#database-installation\"><span class=\"std std-ref\">database installation information</span></a>。</p>\n</section>\n<section id=\"remove-any-old-versions-of-django\">\n<h2>移除任何老版本的 Django<a class=\"heading-anchor\" href=\"#remove-any-old-versions-of-django\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>如果你打算从前一版本的 Django 升级，, 你将需要 <a class=\"reference internal\" href=\"/zh-hans/2.0/topics/install/#removing-old-versions-of-django\"><span class=\"std std-ref\">uninstall the old Django version before installing the new version</span></a>。</p>\n</section>\n<section id=\"install-django\">\n<h2>安装 Django<a class=\"heading-anchor\" href=\"#install-django\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>你有三个简单的方法来安装 Django：</p>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"/zh-hans/2.0/topics/install/#installing-official-release\"><span class=\"std std-ref\">Install an official release</span></a> 适合大部分用户。</p></li>\n<li><p>安装 Django <a class=\"reference internal\" href=\"/zh-hans/2.0/topics/install/#installing-distribution-package\"><span class=\"std std-ref\">provided by your operating system distribution</span></a>。</p></li>\n<li><p><a class=\"reference internal\" href=\"/zh-hans/2.0/topics/install/#installing-development-version\"><span class=\"std std-ref\">Install the latest development version</span></a> 这个选择是针对那些想要体验最新和最好的特性的爱好者们，并不怕运行全新代码。你在开发版中可能会遇到新的 bug，可以报告给社区团队帮助 Django 开发。此外，第三方发行的软件包也可能不与开发版进行兼容。</p></li>\n</ul>\n<aside class=\"admonition-always-refer-to-the-documentation-that-corresponds-to-the-version-of-django-you-re-using admonition\">\n<p class=\"admonition-title\">请始终参考与你所使用的版本对应的 Django 文档！</p>\n<p>如果采用了前两种方式进行安装，你需要注意在文档中标明  <strong>在开发版中新增</strong>。这个标记表明这个特性仅适用开发版 Django，并且他们可能不会在官方发布的稳定版中出现。</p>\n</aside>\n</section>\n<section id=\"verifying\">\n<h2>验证<a class=\"heading-anchor\" href=\"#verifying\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>若要验证 Django 是否能被 Python 识别，可以在 shell 中输入 <code class=\"docutils literal notranslate\"><span class=\"pre\">python</span></code>。 然后在 Python 提示符下，尝试导入 Django：</p>\n<pre class=\"literal-block\">&gt;&gt;&gt; import django\n&gt;&gt;&gt; print(django.get_version())\n2.0</pre>\n<p>当然了，你也可能安装的是其它版本的 Django。</p>\n</section>\n<section id=\"that-s-it\">\n<h2>搞定！<a class=\"heading-anchor\" href=\"#that-s-it\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>搞定，现在你可以 <a class=\"reference internal\" href=\"/zh-hans/2.0/intro/tutorial01/\"><span class=\"doc\">move onto the tutorial</span></a>。</p>\n</section>","rootId":"quick-install-guide","toc":[{"title":"安装 Python","anchor":"install-python","children":[]},{"title":"设置数据库","anchor":"set-up-a-database","children":[]},{"title":"移除任何老版本的 Django","anchor":"remove-any-old-versions-of-django","children":[]},{"title":"安装 Django","anchor":"install-django","children":[]},{"title":"验证","anchor":"verifying","children":[]},{"title":"搞定！","anchor":"that-s-it","children":[]}],"breadcrumbs":[{"docname":"intro/index","title":"开始","url":"/zh-hans/2.0/intro/"}],"prev":{"docname":"intro/overview","title":"初识 Django","url":"/zh-hans/2.0/intro/overview/"},"next":{"docname":"intro/tutorial01","title":"编写你的第一个 Django 应用，第 1 部分","url":"/zh-hans/2.0/intro/tutorial01/"},"formats":{"html":"/zh-hans/2.0/intro/install/","markdown":"/zh-hans/2.0/intro/install.md","json":"/zh-hans/2.0/intro/install.json"},"source":"https://github.com/django/django/blob/stable/2.0.x/docs/intro/install.txt","official":"https://docs.djangoproject.com/zh-hans/2.0/intro/install/","inVersions":["6.1","6.0","5.2","5.1","5.0","4.2","4.1","4.0","3.2","3.1","3.0","2.2","2.1","2.0"],"inLocales":["en","zh-hans","fr","ja","id","pt-br","ko","es","el","pl"]}