Environment variables are dynamic, user-definable values that can influence the behavior of running processes on a computer. They serve as a means to configure applications without altering the underlying code, enabling flexibility and adaptability in software development. Basically is a KEY=VALUE
pair.
There are two types of environment variables:
- Regular environment variables
- System environment variables (can be user specific or public)
PATH Variable
The PATH
environment variable is a list of directories that the operating system searches to find executable files when you enter a command.
- On Unix-like systems, directories are separated by colons (
:
) - On Windows, they are separated by semicolons (
;
) - Order matters, the system checks directories from left to right, executing the first match it finds
Interacting via Python
Alternatively, for local development, it’s common to store environment variables in a .env
file. This file contains key-value pairs and can be loaded into the application using the python-dotenv library.