venv (virtual environment) – explained simply
A venv is a separate folder with its own Python packages, so different AI tools don't interfere with each other.
Also: virtual environment, Virtual Environment, virtualenv, .venv
Different tools often need different versions of the same packages. If you install everything into one shared Python, the second tool might break the first. A virtual environment is like a separate toolbox for each project: whatever you put in it stays there.
According to the Python documentation, you create one with python -m venv followed by the folder name, for example python -m venv .venv. On Windows, activate it in PowerShell with .venv\Scripts\Activate.ps1, and in Command Prompt with .venv\Scripts\activate.bat. You can leave it with deactivate.
A venv is considered disposable: if something breaks, delete the folder and create it again instead of repairing or moving it.
What does that mean for you? Make sure the correct venv is active before you install anything with pip; otherwise the package ends up in the wrong Python.
Related terms
Errors where that matters
- A module that was compiled using NumPy 1.x cannot be run in NumPy 2.x – a package does not match the installed NumPy version
- A1111/Forge: Torch is not able to use GPU
- A1111: INCOMPATIBLE PYTHON VERSION / Couldn't install torch
- AMD Radeon is not being used, PyTorch is running on the CPU
- CUDAExecutionProvider is not in available provider names (onnxruntime runs only on the CPU)
- Failed building wheel for insightface (insightface for ReActor/IPAdapter FaceID won’t install)
- ffmpeg is required for video outputs and could not be found (Video Combine cannot save a video)
- Frontend package outdated after update (comfyui-frontend-package)
- ImportError: DLL load failed while importing …: The specified module could not be found – a Python package is missing a Windows DLL
- Intel Arc not recognized (torch.xpu)
- module 'torch' has no attribute 'float8_e4m3fn' (PyTorch too old for fp8)
- No matching distribution found for torch (wrong Python version)
- No module named 'sageattention' (starting with --use-sage-attention fails)
- No module named 'triton' on Windows (triton-windows missing)
- No module named … (missing Python package for custom node)
- OSError: CUDA_HOME environment variable is not set (CUDA toolkit with nvcc is missing during compilation)
- pip install TTS: No matching distribution found for TTS (Coqui TTS does not fit your Python version)
- pip: error: externally-managed-environment (Linux/WSL)
- pip: Microsoft Visual C++ 14.0 or greater is required
- Stability Matrix: module '__main__' has no attribute '__file__'
- Stable diffusion model failed to load (model can’t be loaded — the real cause is above)
- text-generation-webui: ModuleNotFoundError: No module named 'llama_cpp_binaries' (llama.cpp loader missing after update)
- Torch not compiled with CUDA enabled
- Transformers: FlashAttention2 has been toggled on, but … flash_attn seems to be not installed (FlashAttention missing)
- venv activation blocked: running scripts is disabled on this system