Setting Up Environment
Before writing any Flask code, you need a clean Python environment. A virtual environment keeps your project dependencies isolated, preventing conflicts between different projects.
Why a Virtual Environment?
Different projects may need different versions of Flask or other packages. A virtual environment creates a separate folder with its own Python interpreter and package installation.
Creating a Virtual Environment (Windows)
python -m venv flask-env
flask-envScriptsactivateCreating a Virtual Environment (Mac/Linux)
python3 -m venv flask-env
source flask-env/bin/activateVerifying the Environment
After activation, your terminal prompt should show `(flask-env)`. Run:
where python # Windows
which python # Mac/LinuxIt should point to the virtual environment folder.Two Minute Drill
- Virtual environments isolate project dependencies.
- Create with `python -m venv env_name`.
- Activate: `env_nameScriptsactivate` (Windows) or `source env_name/bin/activate` (Mac/Linux).
- Always work inside a virtual environment for Flask projects.
Need more clarification?
Drop us an email at career@quipoinfotech.com
