Before we can start working on our Flask app, we need to install Flask and create a virtual environment. A virtual environment is a way of isolating the dependencies of our project from the rest of the system, so that we can avoid conflicts and ensure reproducibility.
To install Flask, we can use the pip package manager. Pip is a tool that allows us to install and manage Python packages from the Python Package Index (PyPI). To install Flask, we can run the following command in the terminal:
pip install flask
This will download and install Flask and its dependencies. You can check the version of Flask that you have installed by running:
flask --version
You should see something like this:
Flask 2.0.2
Python 3.9.7
To create a virtual environment, we can use the venv module that comes with Python. Venv is a tool that creates a directory that contains a copy of the Python interpreter and the packages that we need for our project. To create a virtual environment, we can run the following command in the terminal:
python -m venv venv
This will create a directory called venv in the current working directory. To activate the virtual environment, we can run the following command in the terminal:
source venv/bin/activate
This will change the prompt to indicate that we are in the virtual environment. You should see something like this:
(venv) $
Now, we can install Flask and any other packages that we need for our project in the virtual environment. To deactivate the virtual environment, we can run the following command in the terminal:
deactivate
This will return us to the normal prompt. You should see something like this:
$
Original Post: https://enceladus-software.com/post/149
Top comments (1)
The order of installation 🤗 ensuring flask installation on correct environment;
For me, I have set
on my
.bashrc
to force me to have environments before installing packages 📦