Virtual Environments
Virtual environments create isolated workspaces for each project, preventing conflicts between dependencies that require different versions of the same package. This guide covers virtual environment approaches for Python (uv, venv, conda), R (renv), Stata (repado), and Docker containers. For detailed guidance, see the individual pages for each tool.
Python Virtual Environments
Python offers several approaches to virtual environments:
- uv (Recommended): A fast, modern Python package manager that simplifies environment and dependency management
- venv: Python’s built-in virtual environment tool
- conda: Popular environment manager, especially for scientific computing
See Python Virtual Environments with uv for our recommended approach, using uv, for creating and managing Python virtual environments.
R Virtual Environments
R virtual environments can be created using the renv package. See documentation for more information about how to use renv.
Stata Virtual Environments
While Stata does not have a native, versioned package repository that enables virtual environments identical to those in R and Python, you can still achieve similar functionality for reproducible workflows. The repado command in the repkit package helps manage ado dependencies and supports more consistent, portable Stata environments across machines and over time. See the repado documentation and tutorial developed by the World Bank DIME Analytics unit.
Docker Containers
Docker is a containerization platform that packages applications and their dependencies into portable containers. Docker is particularly useful when:
- Deploying projects to cloud computing services
- Managing complex multi-language environments
- Ensuring reproducibility across different systems
- Isolating system-level dependencies
For a complete guide to using Docker for research projects, see the Docker Containers page.