Help us understand the problem. What is going on with this article?

windows10にPythonをインストールしてDjangoを動かすまで

MinicondaでPythonをインストール

  • Miniconda — Conda documentation
    • インストール先をC:\Miniconda3に変更
    • まあ別にどこでもいいけどパスは短いほうが楽だと思った
    • それ以外はデフォルト

環境変数を設定

  • システム環境変数に追加
    • C:\Miniconda3
    • C:\Miniconda3\Scripts
    • C:\Miniconda3\Library\bin
C:\>python -V
Python 3.7.3

C:\>conda -V
conda 4.6.14

仮想環境を作成

C:\>conda create -n myenv python=3.7.3

実行ログ
Collecting package metadata: done
Solving environment: done

## Package Plan ##

  environment location: C:\Miniconda3\envs\myenv

  added / updated specs:
    - python=3.7.3


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    pip-19.1.1                 |           py37_0         1.8 MB
    python-3.7.3               |       h8c8aaf0_1        17.8 MB
    setuptools-41.0.1          |           py37_0         680 KB
    sqlite-3.28.0              |       he774522_0         945 KB
    vs2015_runtime-14.15.26706 |       h3a45250_4         2.4 MB
    wheel-0.33.4               |           py37_0          57 KB
    ------------------------------------------------------------
                                           Total:        23.6 MB

The following NEW packages will be INSTALLED:

  ca-certificates    pkgs/main/win-64::ca-certificates-2019.1.23-0
  certifi            pkgs/main/win-64::certifi-2019.3.9-py37_0
  openssl            pkgs/main/win-64::openssl-1.1.1b-he774522_1
  pip                pkgs/main/win-64::pip-19.1.1-py37_0
  python             pkgs/main/win-64::python-3.7.3-h8c8aaf0_1
  setuptools         pkgs/main/win-64::setuptools-41.0.1-py37_0
  sqlite             pkgs/main/win-64::sqlite-3.28.0-he774522_0
  vc                 pkgs/main/win-64::vc-14.1-h0510ff6_4
  vs2015_runtime     pkgs/main/win-64::vs2015_runtime-14.15.26706-h3a45250_4
  wheel              pkgs/main/win-64::wheel-0.33.4-py37_0
  wincertstore       pkgs/main/win-64::wincertstore-0.2-py37_0


Proceed ([y]/n)? y

Downloading and Extracting Packages
setuptools-41.0.1    | 680 KB    | ############################################################# | 100%
python-3.7.3         | 17.8 MB   | ############################################################# | 100%
pip-19.1.1           | 1.8 MB    | ############################################################# | 100%
sqlite-3.28.0        | 945 KB    | ############################################################# | 100%
wheel-0.33.4         | 57 KB     | ############################################################# | 100%
vs2015_runtime-14.15 | 2.4 MB    | ############################################################# | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use:
# > activate myenv
#
# To deactivate an active environment, use:
# > deactivate
#
# * for power-users using bash, you must source
#

仮想環境を起動

C:\>activate myenv

(myenv) C:\>

毎回コマンドを叩くのは面倒なのでバッチを作る
プロジェクトを作りたいディレクトリにバッチを置いて叩く

C:\Projects\activate-myenv.bat
@echo off
cmd /k "activate myenv"
叩くとこうなる
(myenv) C:\Projects>

Djangoをインストール

(myenv) C:\Projects>pip install django==2.2.1

実行ログ
Collecting django==2.2.1
  Downloading https://files.pythonhosted.org/packages/b1/1d/2476110614367adfb079a9bc718621f9fc8351e9214e1750cae1832d4090/Django-2.2.1-py3-none-any.whl (7.4MB)
     |████████████████████████████████| 7.5MB 544kB/s
Collecting pytz (from django==2.2.1)
  Downloading https://files.pythonhosted.org/packages/3d/73/fe30c2daaaa0713420d0382b16fbb761409f532c56bdcc514bf7b6262bb6/pytz-2019.1-py2.py3-none-any.whl (510kB)
     |████████████████████████████████| 512kB 467kB/s
Collecting sqlparse (from django==2.2.1)
  Downloading https://files.pythonhosted.org/packages/ef/53/900f7d2a54557c6a37886585a91336520e5539e3ae2423ff1102daf4f3a7/sqlparse-0.3.0-py2.py3-none-any.whl
Installing collected packages: pytz, sqlparse, django
Successfully installed django-2.2.1 pytz-2019.1 sqlparse-0.3.0

プロジェクトを作成

(myenv) C:\Projects>django-admin startproject myproj

開発サーバを起動

プロジェクト内に移動
(myenv) C:\Projects>cd myproj
開発サーバを起動
(myenv) C:\Projects\myproj>python manage.py runserver localhost:8080

実行ログ
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).

You have 17 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
May 23, 2019 - 22:51:39
Django version 2.2.1, using settings 'myproj.settings'
Starting development server at http://localhost:8080/
Quit the server with CTRL-BREAK.

毎回コマンドを叩くのは面倒なのでバッチを作る
プロジェクト内にバッチを置いて叩く

C:\Projects\myproj\runserver.bat
@echo off
cmd /k "activate myenv & python manage.py runserver localhost:8080"

ウェブサイトを開く

  • http://localhost:8080/にアクセスする
    • ロケットが表示されてればOK

 The install worked successfully! Congratulations! 

公式ドキュメント

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした