PCAP Modules and Packages Practice Question
A team is using a shared Python environment where multiple projects have conflicting dependencies. Which approach is the best practice to isolate project dependencies?
⚠ Common exam trap
Test-takers frequently think `pip install --user` provides isolation similar to a virtual environment, but it only separates user-level from system-level packages, not between projects, so it fails to solve the core problem of conflicting dependencies across multiple projects.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Create a virtual environment using 'python -m venv' and install dependencies inside it.
Using `python -m venv` creates an isolated virtual environment with its own `site-packages` directory, preventing dependency conflicts between projects. This is the standard best practice recommended by the Python Packaging Authority (PyPA) for managing project-specific dependencies without affecting the system-wide Python installation.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Create a virtual environment using 'python -m venv' and install dependencies inside it.
Why this is correct
Using 'python -m venv' creates an isolated environment with its own Python binary and site-packages directory, allowing each project to install exactly the dependencies and versions it needs without interfering with other projects. This is the standard, built-in best practice for managing project dependencies in a shared Python environment, and it also makes it easy to generate a reproducible requirements.txt for teammates.
- ✗
Manually modify sys.path in each script to include different package directories.
Why it's wrong here
Manually editing sys.path in each script is brittle because it relies on hard-coded absolute filesystem paths that may differ across machines, virtual environments, or after directory restructuring. It also does not provide any isolation; packages with the same name are resolved by the order of paths, leading to unpredictable shadowing and version conflicts. This approach is impossible to maintain across a team and offers no dependency management.
- ✗
Install all dependencies in the system-wide site-packages directory.
Why it's wrong here
Installing all dependencies into the system-wide site-packages makes them globally visible to every Python process on the machine, which means any project requiring a different version of the same package will break or need to be downgraded. This quickly leads to dependency hell, and on modern Linux distributions the system Python is protected by PEP 668, which blocks such global installs without flags. It also requires administrator privileges and risks corrupting the base Python installation.
- ✗
Install all packages using 'pip install --user' to avoid system conflicts.
Why it's wrong here
'pip install --user' installs packages to the current user's site-packages directory, which is still a single shared namespace for every project run by that user. It does not create a per-project environment, so version conflicts remain whenever two projects need different versions of the same library. Moreover, in a team setting, it does not help with a shared host because each user's --user directory is separate and not reproducible for other teammates.
Go deeper
Related to this question
About these practice questions
Courseiva writes every PCAP question from scratch — 169 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This PCAP practice question is part of Courseiva's free Python Institute certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCAP exam.