| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
Managing dependencies for different projects can be challenging. For instance:
Installing libraries globally can lead to version conflicts, often called "dependency hell," where updating a library for one project breaks another.
Virtual environments solve this by creating isolated directories for each project. Each environment contains:
This ensures that project dependencies are kept separate and self-contained.
Python 3 includes a built-in module, venv, which is the standard way to create virtual environments.
python3 -m venv .venvCreating the environment isn't enough; you must activate it for your current shell session. Activation modifies your shell's PATH environment variable, ensuring that the python and pip commands prioritize the versions inside the .venv directory.
With the environment active, use pip to install packages. They will be installed only within the active virtual environment:
pip install <package_name>
# Example: pip install boto3To exit the virtual environment and return to your global Python context, simply run:
deactivateThe indicator (e.g., (.venv)) will disappear from your prompt.
Using venv means packages are installed within your project's .venv directory, which is owned by your user. This eliminates the need and the risks associated with using sudo pip install. Always install project dependencies into an activated virtual environment using pip install <package>.
| Back | FazBrowse Home | New Git URL |