{"title":"Windows での Django のインストール方法","version":"4.2","locale":"ja","docname":"howto/windows","url":"/ja/4.2/howto/windows/","canonical":"https://djangodocs.dev/ja/4.2/howto/windows/","summary":"This document will guide you through installing Python 3.8 and Django on Windows.","html":"<h1>Windows での Django のインストール方法<a class=\"heading-anchor\" href=\"#how-to-install-django-on-windows\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p>This document will guide you through installing Python 3.8 and Django on\nWindows. It also provides instructions for setting up a virtual environment,\nwhich makes it easier to work on Python projects. This is meant as a beginner's\nguide for users working on Django projects and does not reflect how Django\nshould be installed when developing patches for Django itself.</p>\n<p>このガイドの手順は、Windows 10でテストされています。他のバージョンでも手順は似ています。 Windows のコマンドプロンプトの使い方に精通している必要があります。</p>\n<section id=\"install-python\">\n<span id=\"install-python-windows\"></span><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>Django は Python のウェブフレームワークなので、コンピュータには Python がインストールしておく必要があります。この記事を書いている時点では、Python 3.8 が最新版です。</p>\n<p>To install Python on your machine go to <a class=\"reference external\" href=\"https://www.python.org/downloads/\">https://www.python.org/downloads/</a>. The\nwebsite should offer you a download button for the latest Python version.\nDownload the executable installer and run it. Check the boxes next to &quot;Install\nlauncher for all users (recommended)&quot; then click &quot;Install Now&quot;.</p>\n<p>インストール後、コマンドプロンプトを開き、次のコマンドを実行して、Python のバージョンが今インストールしたバージョンと一致するかどうか確認します。</p>\n<div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</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=\"Windows code\"><code><span class=\"gp\">...\\&gt;</span> py --version\n</code></pre></div>\n<aside class=\"admonition admonition-seealso\" role=\"note\">\n<p class=\"admonition-title\">参考</p>\n<p>詳細は <a class=\"reference external\" href=\"https://docs.python.org/3/using/windows.html\" title=\"(in Python v3.14)\"><span>Using Python on Windows</span></a> ドキュメントを参照してください。</p>\n</aside>\n</section>\n<section id=\"about-pip\">\n<h2><code class=\"docutils literal notranslate\">pip</code> について<a class=\"heading-anchor\" href=\"#about-pip\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p><a class=\"extlink-pypi reference external\" href=\"https://pypi.org/project/pip/\">pip</a> is a package manager for Python and is included by default with the\nPython installer. It helps to install and uninstall Python packages\n(such as Django!). For the rest of the installation, we'll use <code class=\"docutils literal notranslate\">pip</code> to\ninstall Python packages from the command line.</p>\n</section>\n<section id=\"setting-up-a-virtual-environment\">\n<span id=\"virtualenvironment\"></span><h2>仮想環境の構築<a class=\"heading-anchor\" href=\"#setting-up-a-virtual-environment\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>It is best practice to provide a dedicated environment for each Django project\nyou create. There are many options to manage environments and packages within\nthe Python ecosystem, some of which are recommended in the <a class=\"reference external\" href=\"https://packaging.python.org/guides/tool-recommendations/\">Python\ndocumentation</a>.\nPython itself comes with <a class=\"reference external\" href=\"https://docs.python.org/3/tutorial/venv.html\" title=\"(in Python v3.14)\"><span class=\"xref std std-doc\">venv</span></a> for managing\nenvironments which we will use for this guide.</p>\n<p>プロジェクトの仮想環境を作成するには、新しいコマンドプロンプトを開き、プロジェクトを作成するフォルダに移動して、次のように入力します：</p>\n<div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</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=\"Windows code\"><code><span class=\"gp\">...\\&gt;</span> py -m venv project-name\n</code></pre></div>\n<p>これにより、'project-name'というフォルダーがまだ存在しなければ作成され、仮想環境が構築されます。環境をアクティブにするには、以下を実行します：</p>\n<div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</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=\"Windows code\"><code><span class=\"gp\">...\\&gt;</span> project-name\\Scripts\\activate.bat\n</code></pre></div>\n<p>The virtual environment will be activated and you'll see &quot;(project-name)&quot; next\nto the command prompt to designate that. Each time you start a new command\nprompt, you'll need to activate the environment again.</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 は仮想環境内で <code class=\"docutils literal notranslate\">pip</code> を使って簡単にインストールできます。</p>\n<p>コマンドプロンプトで、仮想環境がアクティブであることを確認して、以下のコマンドを実行します：</p>\n<div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</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=\"Windows code\"><code><span class=\"gp\">...\\&gt;</span> py -m pip install Django\n</code></pre></div>\n<p>これにより、Django の最新版のリリースがダウンロードされ、インストールされます。</p>\n<p>インストールが完了したら、コマンドプロンプトで <code class=\"docutils literal notranslate\">django-admin --version</code> というコマンドを実行することで、Django が正しくインストールされたかどうかを確認することができます。</p>\n<p>Django とともにデータベースをインストールするための情報については、 <a class=\"reference internal\" href=\"/ja/4.2/topics/install/#database-installation\"><span class=\"std std-ref\">データベースを動かす</span></a> を参照してください。</p>\n</section>\n<section id=\"colored-terminal-output\">\n<h2>ターミナルのカラー出力<a class=\"heading-anchor\" href=\"#colored-terminal-output\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>A quality-of-life feature adds colored (rather than monochrome) output to the\nterminal. In modern terminals this should work for both CMD and PowerShell. If\nfor some reason this needs to be disabled, set the environmental variable\n<span class=\"target\" id=\"index-0\"></span><a class=\"reference internal\" href=\"/ja/4.2/ref/django-admin/#envvar-DJANGO_COLORS\"><code class=\"xref std std-envvar docutils literal notranslate\">DJANGO_COLORS</code></a> to <code class=\"docutils literal notranslate\">nocolor</code>.</p>\n<p>On older Windows versions, or legacy terminals, <a class=\"extlink-pypi reference external\" href=\"https://pypi.org/project/colorama/\">colorama</a> must be\ninstalled to enable syntax coloring:</p>\n<div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</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=\"Windows code\"><code><span class=\"gp\">...\\&gt;</span> py -m pip install colorama\n</code></pre></div>\n<p>See <a class=\"reference internal\" href=\"/ja/4.2/ref/django-admin/#syntax-coloring\"><span class=\"std std-ref\">Syntax coloring</span></a> for more information on color settings.</p>\n</section>\n<section id=\"common-pitfalls\">\n<h2>よくある落とし穴<a class=\"heading-anchor\" href=\"#common-pitfalls\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<ul>\n<li><p>どんな引数を与えても <code class=\"docutils literal notranslate\">django-admin</code> がヘルプテキストしか表示してくれない場合、Windows のファイルの関連付けに問題がある可能性があります。<code class=\"docutils literal notranslate\">PATH</code> に Python のスクリプトを実行するのに必要な環境変数が2つ以上設定されていないかどうか確認してください。2つ以上のバージョンの Python をインストールした時にこの問題が起こることがあります。</p></li>\n<li><p>If you are connecting to the internet behind a proxy, there might be problems\nin running the command <code class=\"docutils literal notranslate\">py -m pip install Django</code>. Set the environment\nvariables for proxy configuration in the command prompt as follows:</p>\n<div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</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=\"Windows code\"><code><span class=\"gp\">...\\&gt;</span> <span class=\"k\">set</span> <span class=\"nv\">http_proxy</span><span class=\"p\">=</span>http://username:password@proxyserver:proxyport\n<span class=\"gp\">...\\&gt;</span> <span class=\"k\">set</span> <span class=\"nv\">https_proxy</span><span class=\"p\">=</span>https://username:password@proxyserver:proxyport\n</code></pre></div>\n</li>\n<li><p>In general, Django assumes that <code class=\"docutils literal notranslate\">UTF-8</code> encoding is used for I/O. This may\ncause problems if your system is set to use a different encoding. Recent\nversions of Python allow setting the <span class=\"target\" id=\"index-1\"></span><a class=\"reference external\" href=\"https://docs.python.org/3/using/cmdline.html#envvar-PYTHONUTF8\" title=\"(in Python v3.14)\"><code class=\"xref std std-envvar docutils literal notranslate\">PYTHONUTF8</code></a> environment\nvariable in order to force a <code class=\"docutils literal notranslate\">UTF-8</code> encoding. Windows 10 also provides a\nsystem-wide setting by checking <code class=\"docutils literal notranslate\">Use Unicode UTF-8 for worldwide language\nsupport</code> in <span class=\"menuselection\">Language ‣ Administrative Language Settings\n‣ Change system locale</span> in system settings.</p></li>\n</ul>\n</section>","rootId":"how-to-install-django-on-windows","toc":[{"title":"Python をインストールする","anchor":"install-python","children":[]},{"title":"pip について","anchor":"about-pip","children":[]},{"title":"仮想環境の構築","anchor":"setting-up-a-virtual-environment","children":[]},{"title":"Django をインストールする","anchor":"install-django","children":[]},{"title":"ターミナルのカラー出力","anchor":"colored-terminal-output","children":[]},{"title":"よくある落とし穴","anchor":"common-pitfalls","children":[]}],"breadcrumbs":[{"docname":"howto/index","title":"「How-to」ガイド","url":"/ja/4.2/howto/"}],"prev":{"docname":"howto/static-files/deployment","title":"静的ファイルをデプロイする","url":"/ja/4.2/howto/static-files/deployment/"},"next":{"docname":"howto/writing-migrations","title":"データベースのマイグレーションの作成方法","url":"/ja/4.2/howto/writing-migrations/"},"formats":{"html":"/ja/4.2/howto/windows/","markdown":"/ja/4.2/howto/windows.md","json":"/ja/4.2/howto/windows.json"},"source":"https://github.com/django/django/blob/stable/4.2.x/docs/howto/windows.txt","official":"https://docs.djangoproject.com/ja/4.2/howto/windows/","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","1.11","1.10","1.9"],"inLocales":["en","zh-hans","fr","ja","id","it","pt-br","ko","es","el","pl"]}