Are you a Python developer eager to explore the world of web development? Flask, a popular micro web framework, is an excellent starting point. In this guide, we'll walk you through the process of installing Flask in Visual Studio Code (VS Code), a powerful and flexible code editor. By the end of this article, you'll have Flask up and running in VS Code, ready to build your first web application.
Prerequisites
Before we begin, ensure you have the following prerequisites installed:
- Python (3.6 or later) - Download and install from the official Python website.
- Visual Studio Code - Download and install from the official VS Code website.
Installing Flask
Flask is a package, and like other Python packages, it can be installed using pip, Python's package installer. Here's how to install Flask in VS Code:

Opening the integrated terminal
VS Code has a built-in terminal that allows you to run commands directly from the editor. To open it, press Ctrl + ` (backtick) or go to View > Terminal.
Installing Flask
Now that the terminal is open, you can install Flask by running the following command:
pip install flask

If you prefer to install Flask in a virtual environment (recommended), create a new virtual environment first using the command python -m venv myenv, then activate it with source myenv/bin/activate (on Linux/macOS) or myenv\Scripts\activate (on Windows), and finally install Flask with pip install flask.
Verifying the Installation
To ensure Flask is installed correctly, create a new Python file (e.g., test_flask.py) in VS Code and add the following code:
```python from flask import Flask app = Flask(__name__) @app.route('/') def home(): return 'Hello, World!' if __name__ == '__main__': app.run(debug=True) ```
Save the file and run it using the integrated terminal with the command python test_flask.py. If everything is set up correctly, you should see output similar to the following:

```bash * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) ```
Open your web browser and navigate to http://127.0.0.1:5000/. You should see the message "Hello, World!" - congratulations, you've just run your first Flask application!
Using an Extension for Flask Development
While you can develop Flask applications using just Python and VS Code, installing an extension can greatly enhance your productivity. One popular extension is Python by Don Jayamanne. This extension provides features like linting, debugging, code navigation, and more. To install it, open VS Code, press Ctrl + Shift + X, search for "Python" in the Extensions view, and click Install.
Conclusion
In this guide, we've walked you through the process of installing Flask in VS Code and verified the installation by running a simple Flask application. With Flask up and running, you're now ready to start building web applications using this powerful micro framework. Happy coding!






















