What is venv and why is it used?
venv (virtual environment) is a standard Python module used to create isolated environments for Python projects. It prevents dependency conflicts between projects by installing packages locally.
What is the standard command to create a new virtual environment named my_env?
python3 -m venv my_env (or just python -m venv my_env on some systems). This creates the my_env directory containing a copy of the Python interpreter and support files.
What is the command to activate an environment named my_env on Linux/macOS?
source my_env/bin/activate
What is the command to activate an environment named my_env on Windows (Command Prompt/PowerShell)?
Command Prompt: my_env\Scripts\activate.bat<br></br>PowerShell: my_env\Scripts\Activate.ps1
How do you know a virtual environment is active?
The name of the active environment (e.g., (my_env)) is prepended to your shell prompt.
Once an environment is active, what does the pip install command do?
pip install installs packages only into the active virtual environment, not globally on your system.
What is the command to deactivate the currently active virtual environment?
deactivate
If you delete the my_env directory while the environment is inactive, what happens?
The environment is permanently deleted. There is no need for a special “uninstall” command.
What command do you use to share a list of installed packages from your active environment with others?
pip freeze > requirements.txt (This creates a file listing all exact package versions.)
What command is used to install all dependencies listed in a requirements.txt file into an active environment?
pip install -r requirements.txt