-
Hajipur, Bihar, 844101
A Virtual Environment in Python is a self-contained directory that contains a Python installation for a specific project. It keeps dependencies isolated from your global Python setup.
Prevents dependency conflicts between projects
Keeps your project environment clean and manageable
Lets you use different versions of packages for different projects
Use the built-in venv
module:
python -m venv myenv
✅ This will create a folder named myenv
with the virtual environment inside it.
myenv\Scripts\activate
source myenv/bin/activate
✅ Once activated, your terminal will show the environment name like:(myenv) C:\Users\...>
Now that you're inside the virtual environment, use pip
as usual:
pip install flask
The installed packages stay isolated from your system Python.
When you're done:
deactivate
✅ You’ll exit the virtual environment and return to your global Python path.
Just delete the folder:
rm -r myenv
pip list
You’ll only see packages installed within that environment.
Q1. Write a Python command to create a virtual environment called projectenv
.
Q2. Write a command to activate the virtual environment on Windows.
Q3. Write a command to install the django
package inside the virtual environment.
Q4. Write a command to list all installed packages inside the virtual environment.
Q5. Write a command to deactivate the virtual environment.
Q6. Write a command to create a requirements.txt
file using pip freeze
.
Q7. Write a command to install dependencies from requirements.txt
inside a virtual environment.
Q8. Write a command to delete a virtual environment folder named projectenv
.
Q9. Write a short explanation or command to use a virtual environment to avoid package conflicts.
Q10. Write steps to use different versions of the same package in two separate virtual environments.
Q1: What does a virtual environment do?
Q2: Which command creates a virtual environment?
Q3: How do you activate virtualenv on Windows?
Q4: What does deactivate do in virtualenv?
Q5: Which package manager is used inside virtualenv?
Q6: Where are packages stored in a virtualenv?
Q7: Can you have multiple virtual environments on the same system?
Q8: How do you remove a virtual environment?
Q9: What is the default folder name when creating a virtual environment?
Q10: What command lists installed packages inside virtualenv?