윈도우즈에 Django 설치하기

This document will guide you through installing Python 3.12 and Django on Windows. It also provides instructions for setting up a virtual environment, which makes it easier to work on Python projects. This is meant as a beginner’s guide for users working on Django projects and does not reflect how Django should be installed when developing patches for Django itself.

이 가이드의 단계는 Windows 10에서 테스트되었습니다. 다른 버전에서는 단계가 비슷합니다. Windows(윈도우) 명령 프롬프트를 사용하는 방법을 숙지해야 합니다.

파이썬 설치

Django is a Python web framework, thus requiring Python to be installed on your machine. At the time of writing, Python 3.12 is the latest version.

컴퓨터에 Python을 설치하려면 https://www.python.org/downloads/로 이동합니다. 웹 사이트에서 최신 Python 버전에 대한 다운로드 버튼을 제공해야 합니다. 실행 가능한 설치 프로그램을 다운로드하고 실행합니다. “모든 사용자를 위한 런처 설치(권장)” 옆의 확인란을 선택한 다음 “지금 설치”를 클릭합니다.

After installation, open the command prompt and check that the Python version matches the version you installed by executing:

...\> py --version

더 보기

자세한 내용은:doc:’python:using/window’ 설명서를 참조하십시오.

pip에 대하여

pip is a package manager for Python and is included by default with the Python installer. It helps to install and uninstall Python packages (such as Django!). For the rest of the installation, we’ll use pip to install Python packages from the command line.

가상 환경을 설정합니다.

생성하는 각 Django 프로젝트에 전용 환경을 제공하는 것이 좋습니다. 파이썬 생태계 내 환경 및 패키지를 관리할 수 있는 여러 가지 옵션이 있으며 이 중 일부는 파이썬 설명서(https://packaging.python.org/guides/tool-recommendations/)에 나와 있습니다. Python 자체는 우리가 이 가이드에 사용할 환경을 관리하기 위한 :doc:’venv <python:tutorial/venv’와 함께 제공됩니다.

To create a virtual environment for your project, open a new command prompt, navigate to the folder where you want to create your project and then enter the following:

...\> py -m venv project-name

This will create a folder called ‘project-name’ if it does not already exist and set up the virtual environment. To activate the environment, run:

...\> project-name\Scripts\activate.bat

가상 환경이 활성화되고 명령 프롬프트 옆에 “(프로젝트 이름)”이 표시되어 가상 환경을 지정합니다. 새 명령 프롬프트를 시작할 때마다 환경을 다시 활성화해야 합니다.

장고 설치

Django는 가상 환경 내에서 “pip”을 사용하여 쉽게 설치할 수 있습니다.

In the command prompt, ensure your virtual environment is active, and execute the following command:

...\> py -m pip install Django

그러면 최신 Django 릴리스가 다운로드되고 설치됩니다.

설치가 완료되면 명령 프롬프트에서 “django-admin –version”을 실행하여 Django 설치를 확인할 수 있습니다.

Django와의 데이터베이스 설치에 대한 자세한 내용은:ref:’데이터베이스 설치’를 참조하십시오.

컬러 터미널 출력

삶의 질 기능은 터미널에 (흑백이 아닌) 컬러 출력을 추가합니다. 최신 터미널에서는 CMD와 PowerShell 모두에서 작동합니다. 비활성화해야 하는 경우, 환경 변수 :envvar:`DJANGO_COLORS`를 ``nocolor``로 설정하십시오.

On older Windows versions, or legacy terminals, colorama 0.4.6+ must be installed to enable syntax coloring:

...\> py -m pip install "colorama >= 0.4.6"

색상 설정에 대한 자세한 내용은 :ref:`syntax-coloring`을 참조하세요.

공통적인 함정

  • 만약 “django-admin”이 어떤 주장이 주어지더라도 도움말 텍스트만 표시한다면, 윈도우의 파일 연결에 문제가 있을 것입니다. “PATH”에서 Python 스크립트를 실행하기 위해 둘 이상의 환경 변수가 설정되어 있는지 확인합니다. 일반적으로 Python 버전이 두 개 이상 설치된 경우 이러한 문제가 발생합니다.

  • If you are connecting to the internet behind a proxy, there might be problems in running the command py -m pip install Django. Set the environment variables for proxy configuration in the command prompt as follows:

    ...\> set http_proxy=http://username:password@proxyserver:proxyport
    ...\> set https_proxy=https://username:password@proxyserver:proxyport
    
  • 일반적으로, Django는 UTF-8 인코딩이 I/O에 사용된다고 가정합니다. 시스템이 다른 인코딩을 사용하도록 설정된 경우 이로 인해 문제가 발생할 수 있습니다. 최신 버전의 Python에서는 UTF-8 인코딩을 강제하기 위해 PYTHONUTF8 환경 변수를 설정할 수 있습니다. Windows 10은 또한 시스템 설정의 :menuselection:`언어 –> 관리 언어 설정 –> 시스템 로케일 변경`에서 ``세계 언어 지원에 유니코드 UTF-8 사용``을 선택하여 시스템 전체 설정을 제공합니다.

Back to Top