Python Tutorial: Setting Up Your Flask Development Environment (VS Code)

![[Python 강좌] 2강. Python, Flask 개발 환경 구축하기 (VS Code)](/uploads/editor/Python-%EA%B0%95%EC%A2%8C-2%EA%B0%95-Python-Flask-%EA%B0%9C%EB%B0%9C-%ED%99%98%EA%B2%BD-%EA%B5%AC%EC%B6%95%ED%95%98%EA%B8%B0-VS-Code-20260706-ef00f6.webp)
![[Python 강좌] Python Flask 블로그 만들기, 지금부터 함께 시작합니다.](/uploads/editor/Python-%EA%B0%95%EC%A2%8C-Python-Flask-%EB%B8%94%EB%A1%9C%EA%B7%B8-%EB%A7%8C%EB%93%A4%EA%B8%B0-%EC%A7%80%EA%B8%88%EB%B6%80%ED%84%B0-%ED%95%A8%EA%BB%98-%EC%8B%9C%EC%9E%91%ED%95%A9%EB%8B%88%EB%8B%A4-20260706-614807.webp)
What is a Development Environment?
Before starting programming, the first step is to set up your development environment.
A development environment refers to the process of installing necessary tools required to write and run programs.
Similar to preparing your kitchen and cooking utensils before making a meal, web development requires installing essential software first.
In this lesson, we'll install all the development tools you'll need moving forward.
Programs to Install in This Lesson
In this lesson, we'll install the following programs:
Python
Visual Studio Code (VS Code)
Flask
MySQL (installation only; detailed usage explained in Lesson 6)
All installation steps are based on a Windows environment.
Installing Python
First, let's install Python.
When the installer window appears, make sure to check the following option:
Add Python to PATH
Selecting this option allows you to run Python from any command prompt or PowerShell window.
After checking this option, select Install Now to begin installation.
Once installed, open a command prompt and enter the following command:
python --version
Or alternatively:
py --version
If the version information appears correctly, Python is successfully installed.
Installing Visual Studio Code
Now let's install a code editor to write our code.
In this lesson, we'll use Visual Studio Code (VS Code).
VS Code is lightweight, easy to use, and one of the most popular editors for Python development.
After installation, open VS Code.
Installing the Python Extension
Simply installing VS Code doesn't mean you can start Python development immediately.
You need to install the Python extension from the Extensions marketplace.
This extension provides features like:
Code auto-completion
Syntax highlighting
Error detection
Debugging capabilities
Code execution
While these features may seem basic at first, they become incredibly helpful as you progress with development.
Creating a Project Folder
Now let's create a folder for our project.
You can create it like this:
python-flask-blog
In VS Code, select Open Folder to open the folder you just created.
All future projects will be developed within this folder.
Why Use a Virtual Environment?
In Python, different projects may require different versions of libraries.
To prevent one project's installed libraries from affecting others, we use a virtual environment (Virtual Environment).
In simple terms, it creates a dedicated workspace for each project.
To create a virtual environment, enter the following command in your terminal:
python -m venv venv
After a moment, a venv folder will appear inside your project directory.
Activating Your Virtual Environment
In Windows, you can activate the virtual environment using these commands:
Command Prompt (CMD)
venv\Scripts\activate
PowerShell
.\venv\Scripts\Activate.ps1
When the virtual environment is activated, your terminal prompt will show:
(venv)
If you see this indicator, the environment has been successfully activated.
Installing Flask
Now let's install Flask.
In your terminal, enter the following command:
pip install flask
Once installation completes, Flask is successfully installed.
You can verify the installation by checking with this command:
pip show flask
If package information appears, your setup is complete.
Preparing Your First Flask Project
Create a file named app.py in your project folder.
Most examples will be written in this file moving forward.
In the next lesson, we'll write our first code in this file and run it directly in a web browser.
Although the initial code may only be a few lines, we'll gradually add features to build a complete blog application over time.
Project Folder Structure
Your project should now have this structure:
python-flask-blog/
│
├── venv/
└── app.py
As we progress through the lessons, we'll add HTML files, CSS files, image folders, and database-related files to this structure.
Key Points to Remember
The most important points from this lesson are:
Installing Python
Installing VS Code
Installing the Python extension
Creating a project folder
Creating and activating a virtual environment
Installing Flask
If you've properly completed these six steps, you'll be able to follow all subsequent lessons without issues.
Wrapping Up
Setting up a development environment may feel tedious at first.
However, once configured correctly, you can focus solely on writing and running code going forward.
In the next lesson, we'll create our first Flask program and run it directly in a web browser.
Your journey into Python Flask web development begins now.
FAQ
Why is a virtual environment important?
A virtual environment isolates project dependencies so that libraries installed for one project don't interfere with others, allowing different versions of packages to be used across multiple projects.
What does 'Add Python to PATH' mean?
This option allows you to run Python commands from any location in your command prompt or PowerShell without specifying the full path to the Python executable.
Korean Source
This article is an English localization of a Korean-language report from BlogScore. Original: [Python 강좌] 2강. Python, Flask 개발 환경 구축하기 (VS Code)