What is a Python environment? A Python environment is a space where your Python code runs — with its own installed libraries, dependencies, and version settings. A virtual environment is a private copy of the Python interpreter onto which you can install packages privately. You can have a virtual environment and a system environment. A “virtual environment” is a bubble where only your app lives and runs, with only the libraries you installed for it.
The system environment is global across the system (computer). Every script shares the same set of packages. The Risk: Installing too many packages or conflicting versions can break other projects.
Virtual environments are recommended. It’s a self-contained folder with its own Python + pip + installed packages. Each project has it’s own virtual environment. This way you can isolate dependencies. You can avoid version conflicts. You can work cleanly with Flask, Django, and so on.
Setting up a virtual environment
You only do this once per project, typically at the beginning. Here is what ChatGPT wrote on setting it up.
# Step 1: Navigate to your project folder cd path\to\your\project # Step 2: Create a virtual environment named `venv` python -m venv venv # Step 3: Activate it # On Windows (Command Prompt): venv\Scripts\activate # On PowerShell: .\venv\Scripts\Activate.ps1 # On macOS/Linux: source venv/bin/activate
Once activated, your terminal prompt will change — you’ll see something like this (but probably in a different folder):
(venv) C:\Users\YourName\YourProject>
Here is an example. While it’s active, if you run:
pip install flask flask-mail itsdangerous
those packages install only inside your project’s environment — not system-wide.
Here are some commands you can run to chack your versions, in Windows.
python --version rem or python -V pip --version rem Check if You're in a Virtual Environment: where python # Windows rem or which python # macOS/Linux rem See Installed Packages in Current Environment rem Shows all installed libraries in your current environment — very helpful for blogs or sharing setup details. pip list