Menu Close

Setup Flask Environment

In this Python flask tutorial, we will setup flask environment to build flask applications. In the previous tutorial, we have seen the introduction of Python Flask. In this guide, we will cover step by step process to set a flask environment.

Note:- Before going through this Python flask tutorial, You should have basic knowledge of Python programming. You can follow our Python tutorials.

Install Python

To use Python flask, Python should be installed in your machine. If Python already installed in your machine, Then you can continue with the next step, Otherwise, Click here to download Python according to your system architecture. See our Python installation guide step by step.

Create a folder

Here we will create a separate folder for our flask application. Open your system terminal and execute the following command.


mkdir flask_application
cd flask_application

Create virtual environemnt

In Python, the virtual environment is an isolated Python environment, Which does not affect your global Python environment. You can create Python virtual environment for multiple projects. Each virtual environment is independent.

Open your system terminal inside flask_application folder and execute following command.

python -m venv venv

In the above command, the first venv represents a venv tool that already an installation in your machine during the installation of python, and the second venv represent the virtual environment name, You can keep any name according to your wish.

After created of Python virtual environment, You need to activate it.

Linux

For linux machine, you need to execute below command.

source venv/bin/activate

Windows

For windows machine, you need to execute below command.

venv\Scripts\activate

Now, time to come to install Python flask in a separate virtual environment. Run the following command to install flask.

pip install flask

Conclusion

In this Python flask tutorial, we have seen how to setup flask environment to build a flask application. In the next flask tutorial, we will create our first small flask application, So if you want to learn Python flask from scratch, Then don’t miss our Python flask tutorial.

If you like this setup flask environment article, please share and keep visiting for further Python flask tutorials.

Previous Article
Next Article

Related Posts