Working with virtual environments
How to create a python virtual environment
Create the virtual environment
python -m venv envActivate the virtual environment
- for windows
env\Scripts\activate- for Linux / macOS
source env/bin/activateDeactivate the virtual environment
deactivate
How to set environment variables
for CMD
SET VARIABLE_NAME=VALUESET FLASK_APP=app.py
SET FLASK_ENV=development
SET FLASK_DEBUG=true
SET SQLALCHEMY_DATABASE_URI=postgresql://user:password@host:port/dbnamefor BASH
export VARIABLE_NAME=VALUEexport FLASK_APP=app.py
export FLASK_ENV=development
export FLASK_DEBUG=true
export SQLALCHEMY_DATABASE_URI=postgresql://user:password@host:port/dbnamefor POWERSHELL
$env:VARIABLE_NAME=VALUE$env:FLASK_APP=app.py
$env:FLASK_ENV=development
$env:FLASK_DEBUG=true
$env:SQLALCHEMY_DATABASE_URI=postgresql://user:password@host:port/dbnameConfiguring pyenv on Mac
Create a file called .zshrc in your home directory and add the following scripts to it to enable discovery of active python version.
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"