{"title":"Windows での Django のインストール方法","version":"5.2","locale":"ja","docname":"howto/windows","url":"/ja/5.2/howto/windows/","canonical":"https://djangodocs.dev/ja/5.2/howto/windows/","summary":"このドキュメントでは、WindowsにPython…","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>このドキュメントでは、WindowsにPython 3.14とDjangoをインストールする手順を案内します。また、Pythonプロジェクトの作業を簡単にするための仮想環境のセットアップ方法についても説明しています。これはDjangoプロジェクトに取り組む初心者向けのガイドであり、Django自体の開発を行う場合のインストール方法を示したものではありません。</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.14が最新バージョンです。</p>\n<p>あなたのマシンにPythonをインストールするには、 <a class=\"reference external\" href=\"https://www.python.org/downloads/\">https://www.python.org/downloads/</a> を開きます。最新のPythonバージョンのダウンロードボタンが表示されるはずです。実行可能なインストーラをダウンロードして実行します。 &quot;Install launcher for all users (recommended)&quot; にチェックを入れ、&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-py-is-not-recognized-or-found admonition\">\n<p class=\"admonition-title\"><code class=\"docutils literal notranslate\"><span class=\"pre\">py</span></code> が認識されないか、見つからないとき</p>\n<p>Pythonのインストール方法によっては、コマンドプロンプトで <code class=\"docutils literal notranslate\"><span class=\"pre\">py</span></code> コマンドが使えないことがあります（Microsoft Store経由でインストールした場合など）。</p>\n<p>その場合、 <code class=\"docutils literal notranslate\"><span class=\"pre\">py</span></code> コマンドの代わりに <code class=\"docutils literal notranslate\"><span class=\"pre\">python</span></code> コマンドを使用します。</p>\n</aside>\n<aside class=\"admonition admonition-seealso\">\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\"><span class=\"pre\">pip</span></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> は Python のパッケージマネージャで、Python インストーラにデフォルトで含まれています。Python パッケージ (Django など！) のインストールとアンインストールに役立ちます。残りのインストールでは、 <code class=\"docutils literal notranslate\"><span class=\"pre\">pip</span></code> を使ってコマンドラインから Python パッケージをインストールします。</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>作成する Django プロジェクトごとに専用の環境を用意するのがベストプラクティスです。Python のエコシステム内には、環境やパッケージを管理するための多くのオプションがあり、そのいくつかは <a class=\"reference external\" href=\"https://packaging.python.org/guides/tool-recommendations/\">Python のドキュメント</a> で推奨されています。Python 自身にも環境管理のための <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> が付属しています。</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>仮想環境がアクティブ化され、コマンドプロンプトの隣にそれを示す &quot;(project-name)&quot; が表示されます。新しいコマンドプロンプトを開始するたびに、環境を再度アクティブにする必要があります。</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\"><span class=\"pre\">pip</span></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\"><span class=\"pre\">django-admin</span> <span class=\"pre\">--version</span></code> というコマンドを実行することで、Django が正しくインストールされたかどうかを確認することができます。</p>\n<p>Django とともにデータベースをインストールするための情報については、 <a class=\"reference internal\" href=\"/ja/5.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>クオリティ・オブ・ライフ機能により、ターミナルに（モノクロではなく）色のついた出力が追加されます。最近の端末ではCMDとPowerShellの両方で動作するはずです。何らかの理由で無効にしたい場合は、環境変数 <span class=\"target\" id=\"index-4\"></span><a class=\"reference internal\" href=\"/ja/5.2/ref/django-admin/#envvar-DJANGO_COLORS\"><code class=\"xref std std-envvar docutils literal notranslate\"><span class=\"pre\">DJANGO_COLORS</span></code></a> を <code class=\"docutils literal notranslate\"><span class=\"pre\">nocolor</span></code> に設定してください。</p>\n<p>古いWindowsバージョンやレガシー端末では、シンタックスカラーリングを有効にするには <a class=\"extlink-pypi reference external\" href=\"https://pypi.org/project/colorama/\">colorama</a> 0.4.6 以上をインストールする必要があります:</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 <span class=\"s2\">&quot;colorama &gt;= 0.4.6&quot;</span>\n</code></pre></div>\n<p>色の設定については <a class=\"reference internal\" href=\"/ja/5.2/ref/django-admin/#syntax-coloring\"><span class=\"std std-ref\">シンタックスカラーリング</span></a> を参照してください。</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\"><span class=\"pre\">django-admin</span></code> がヘルプテキストしか表示してくれない場合、Windows のファイルの関連付けに問題がある可能性があります。<code class=\"docutils literal notranslate\"><span class=\"pre\">PATH</span></code> に Python のスクリプトを実行するのに必要な環境変数が2つ以上設定されていないかどうか確認してください。2つ以上のバージョンの Python をインストールした時にこの問題が起こることがあります。</p></li>\n<li><p>プロキシ経由でインターネットに接続している場合、コマンド <code class=\"docutils literal notranslate\"><span class=\"pre\">py</span> <span class=\"pre\">-m</span> <span class=\"pre\">pip</span> <span class=\"pre\">install</span> <span class=\"pre\">Django</span></code> の実行がうまくいかないかもしれません。コマンドプロンプトで、プロキシ設定用の環境変数を以下のように設定してください:</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>一般に、Django は <code class=\"docutils literal notranslate\"><span class=\"pre\">UTF-8</span></code> エンコーディングが入出力に使われることを想定しています。このため、システムが別のエンコーディングを使うように設定されていると、 問題を引き起こすかもしれません。最近のバージョンの Python では、 <span class=\"target\" id=\"index-5\"></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\"><span class=\"pre\">PYTHONUTF8</span></code></a> 環境変数を設定することで、 <code class=\"docutils literal notranslate\"><span class=\"pre\">UTF-8</span></code> エンコーディングを強制できます。Windows 10 では、システム設定の <span class=\"menuselection\">言語 ‣ 管理用の言語の設定 ‣ システム ロケールの変更</span> にある <code class=\"docutils literal notranslate\"><span class=\"pre\">ワールドワイド言語サポートで</span> <span class=\"pre\">Unicode</span> <span class=\"pre\">UTF-8</span> <span class=\"pre\">を使用</span></code> をチェックすることで、システム全体の設定を行うこともできます。</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/5.2/howto/"}],"prev":{"docname":"howto/upgrade-version","title":"Django の新しいバージョンへの更新","url":"/ja/5.2/howto/upgrade-version/"},"next":{"docname":"howto/deployment/index","title":"Djangoをデプロイするには","url":"/ja/5.2/howto/deployment/"},"formats":{"html":"/ja/5.2/howto/windows/","markdown":"/ja/5.2/howto/windows.md","json":"/ja/5.2/howto/windows.json"},"source":"https://github.com/django/django/blob/stable/5.2.x/docs/howto/windows.txt","official":"https://docs.djangoproject.com/ja/5.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","sv","zh-hans","ga","fr","ja","id","it","pt-br","ko","es","el","pl"]}