The Anubhav portal was launched in March 2015 at the behest of the Hon'ble Prime Minister for retiring government officials to leave a record of their experiences while in Govt service .
A Python Virtual Environment (venv) is an isolated environment that allows you to install and manage Python packages
independently from your system-wide Python installation. This helps prevent version conflicts between different projects.
Here’s a quick guide to understanding and using it:
Why Use a Virtual Environment?
Without a venv:
All packages are installed globally (shared by all projects).
Upgrading/downgrading a package may break other projects.
With a venv:
Each project has its own set of dependencies.
Safe to use different package versions in different projects.
How to Create and Use a Virtual Environment
1. Check Python Installation
python --version
# or sometimes
python3 --version
2. Create a Virtual Environment
python -m venv myenv
This creates a folder named myenv containing a private Python setup.
You can change myenv to any name you like.
3. Activate the Virtual Environment
Windows:
myenv\Scripts\activate
macOS/Linux:
source myenv/bin/activate
After activation, your terminal prompt will show:
(myenv) C:\project>
4. Install Packages Inside the venv
pip install requests
Check installed packages:
pip list
5. Freeze Dependencies (optional but important)
Save all installed packages to a file:
pip freeze > requirements.txt
Later, you can recreate the same environment with:
pip install -r requirements.txt
6. Deactivate the Virtual Environment
deactivate
Alternative Tools
Tool
Description
venv
Built into Python 3 — simple and lightweight
virtualenv
Older but feature-rich; works for Python 2 & 3
pipenv
Combines pip + venv + dependency locking
poetry
Modern tool for dependency management and packaging
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Here’s a quick guide to understanding and using it:
Why Use a Virtual Environment?
Without a venv:
With a venv:
How to Create and Use a Virtual Environment
1. Check Python Installation
2. Create a Virtual Environment
myenvcontaining a private Python setup.myenvto any name you like.3. Activate the Virtual Environment
Windows:
macOS/Linux:
After activation, your terminal prompt will show:
4. Install Packages Inside the venv
Check installed packages:
5. Freeze Dependencies (optional but important)
Save all installed packages to a file:
Later, you can recreate the same environment with:
6. Deactivate the Virtual Environment
Alternative Tools
venvvirtualenvpipenvpip+venv+ dependency lockingpoetry