Interview Question

What is virtual environment?

A virtual environment isolates a project’s interpreter context and installed packages.

💡 Concept ✅ Quick Revision 🐍 Python

Answer

A virtual environment is an isolated Python environment with its own installation directories. • It keeps one project’s packages separate from another project or the base interpreter. • The venv module creates lightweight virtual environments. • Activation changes shell paths for convenience but is not required to use the environment’s interpreter.

💡 Simple Example

python -m venv .venv

⚡ Quick Revision

A virtual environment isolates a project’s interpreter context and installed packages.