[PYTHON] Build a Django environment for Win10 (with virtual space)

Overview

Here's how to install Django on a clean Windows 10.

Prerequisites for the construction environment

Environment construction policy

Python installation

Download and install

** Introduction Python. ** **

For Python on Windows 10, it's a good idea to download the official installer. Leave your hands on Anaconda.

The Python version uses ** 3 series **.

The latest version of this article when building the environment is 3.7.4 Download from the bottom of the site below according to your environment. https://www.python.org/downloads/windows/

I selected the installer for 64-bit environment.

Install the downloaded one. At this time, I checked the option to pass the PATH. I think it is off by default.

Check if it was installed

Launch PowerShell for Windows 10 and check the Python version. Windows can use both python and py. It seems that the latest version of py is specified.

PS C:\Users\AKI> python --version
Python 3.7.4
 
PS C:\Users\AKI\django_proj> py --version
Python 3.7.4

Django environment construction

** In this article, Django is built using a Python virtual environment. ** **

A virtual environment is a ** virtual closed space ** that helps keep your computer clean with various Python packages.

** Run Django in this virtual environment. ** **

Prepare a directory for building a Django environment

Create a directory anywhere you like with PowerShell. This time I will make it in my HOME. After creating the directory, move to it.

PS C:\Users\AKI> mkdir django_proj
PS C:\Users\AKI> cd .\django_proj\
PS C:\Users\AKI\django_proj>

Prepare a virtual environment with venv

Build a virtual environment with something called venv.

It seems that virtualenv was used at the time of Python 2 series, but it becomes venv in 3 series and it is in Pyhon by default.

Let's build it. Here, the name of the virtual environment is "env01".

PS C:\Users\AKI\django_proj> python -m venv env01
PS C:\Users\AKI\django_proj> ls
 
env01  <-This folder is created

Then, ** execute activate in the Scripits folder ** to enter the virtual environment.

PS C:\Users\AKI\django_proj> .\env01\Scripts\activate
(env01) PS C:\Users\AKI\django_proj>

(Env01) is displayed at the beginning of the Shell.

** You are now in a virtual environment. ** **

Again, check your Python version.

(env01) PS C:\Users\AKI\django_proj> python --version
Python 3.7.4

Introducing Django

Deploy using pip in a virtual environment.

"Pip" is a system that manages Python libraries and packages. If a beginner puts in Anaconda and does it properly, the package will interfere with pip and the local environment will be chaotic without knowing it.

First, upgrade to the latest version of pip.

(env01) PS C:\Users\AKI\django_proj> python -m pip install --upgrade pip

Enter the command to install.

(env01) PS C:\Users\AKI\django_proj> pip install Django
.
.Various logs flow here
.
Successfully installed Django-2.2.3 pytz-2019.1 sqlparse-0.3.0

Check your Django version.

(env01) PS C:\Users\AKI\django_proj> django-admin --version
2.2.3

By the way, let's launch another Poser Shell here and check the version of Django there.

PS C:\Users\AKI> django-admin --version
 
It is said that there is no such command.

** I was able to build Django only in a virtual environment. ** **

To exit the virtual environment, enter the command as shown below.

(env01) PS C:\Users\AKI\django_proj> deactivate
PS C:\Users\AKI\django_proj>

** Returned to reality. ** **

That's it for building the Django environment.

The next step is Tutorial.

Recommended Posts

Build a Django environment for Win10 (with virtual space)
Build a python virtual environment with pyenv
[DynamoDB] [Docker] Build a development environment for DynamoDB and Django with docker-compose
Start Django in a virtual environment with Pipenv
[Python] Build a Django development environment with Docker
Build a Django environment with Vagrant in 5 minutes
Build a virtual environment with pyenv and venv
Build a Django development environment with Doker Toolbox
Quickly build a Python Django environment with IntelliJ
Steps to build a Django environment with Win10 WSL Ubuntu18.04 + Anaconda + Apache2
Build a python virtual environment with virtualenv and virtualenvwrapper
Build a python environment for each directory with pyenv-virtualenv
Build a Python virtual environment using venv (Django + MySQL ①)
Build a python virtual environment with virtualenv and virtualenvwrapper
Build a development environment with Poetry Django Docker Pycharm
Build python virtual environment with virtualenv
Building a virtual environment with Python 3
Build a web application with Django
Build a Django development environment with Docker! (Docker-compose / Django / postgreSQL / nginx)
[Django] Build a Django container (Docker) development environment quickly with PyCharm
Create a Todo app with Django ① Build an environment with Docker
Install Django in a pipenv virtual environment
Build a Tensorflow environment with Raspberry Pi [2020]
Let's create a virtual environment for Python
[Python] Create a virtual environment with Anaconda
Try using virtualenv, which can build a virtual environment for Python
Build a TOP screen for Django users
Build a Fast API environment with docker-compose
[Mac] Building a virtual environment for Python
Create a virtual environment with Python_Mac version
[Linux] Build a jenkins environment with Docker
I made a development environment for Django 3.0 with Docker, Docker-compose, Poetry
Build a modern Python environment with Neovim
[Linux] Build a Docker environment with Amazon Linux 2
Prepare a Python virtual environment for your project with venv with VS Code
Build a C language development environment with a container
Build a WardPress environment on AWS with pulumi
Build Django + NGINX + PostgreSQL development environment with Docker
Build the fastest Django development environment with docker-compose
Build a Django environment on Raspberry Pi (MySQL)
Build a python environment with ansible on centos6
Create a virtual environment with conda in Python
Create a python3 build environment with Sublime Text3
Create a dashboard for Network devices with Django!
Build a simple Python virtual environment without pyenv
Commands for creating a python3 environment with virtualenv
Work in a virtual environment with Python virtualenv.
Build a Kubernetes environment for development on Ubuntu
Flow of creating a virtual environment with Anaconda
Build a Python environment with OSX El capitan
Build a mruby development environment for ESP32 (Linux)
Build a Python machine learning environment with a container
Build a python execution environment with VS Code
Virtual environment with Python 3.6
Creating an environment for OSS-DB Silver # 1_Create a Linux environment (CentOS7 virtual environment) with VirtualBox/Vagrant
Build a local development environment with WSL + Docker Desktop for Windows + docker-lambda + Python
A memo to create a virtual environment (venv) before Django
Build a local development environment for Laravel6.X on Mac
Create a virtual environment with Anaconda installed via Pyenv
[Linux] WSL2 Build an environment for laravel7 with Ubuntu 20.04
How to build a Django (python) environment on docker