rootutils
Simple package for easy project root setup
What it is and what it does
Rootutils solves a common Python development friction point: ensuring that imports, file paths, and environment variables work consistently regardless of where a script is executed from. It searches up the directory tree for a marker file (like .git, setup.py, or .project-root) to identify your project root, then configures Python's path, working directory, and environment in a single call. The package wraps python-dotenv to load .env files automatically.
The typical workflow is a one-liner at the top of your script or notebook: `rootutils.setup_root(__file__, dotenv=True, pythonpath=True)`. This is especially useful in notebooks nested in subdirectories, where relative imports and file access would otherwise require fragile path manipulation. The package is small, actively maintained, and requires only Python 3.7+.
Use it for:
- Set up Jupyter notebooks in nested directories so they can import modules and access data relative to project root.
- Run Python scripts from any working directory without hardcoding absolute paths or managing PYTHONPATH manually.
- Load environment variables from .env automatically without explicit dotenv.load_dotenv() calls.
- Standardize file access across a project by always resolving paths relative to a marker file like .git.
- Configure CI/CD pipelines to run tests consistently regardless of the runner's working directory.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Finds your project root directory and configures Python path, working directory, and environment variables in one call, so scripts run consistently from anywhere.
Yes. Rootutils is a lightweight, actively maintained utility that solves a genuine pain point in Python development. Low install friction, permissive license, no known vulnerabilities, and a straightforward API make it a safe choice for projects that need reliable project-root discovery and path configuration.
Install
rootutils on PyPI
pip
pip install rootutilsuv
uv add rootutilspoetry
poetry add rootutilsInstalling rootutils
Before you install
Low friction: pure Python wheel with a single runtime dependency (python-dotenv). Maintenance is active with recent commits and a modest but steady user base.
License in practice
MIT license is permissive; you can use, modify, and distribute this package freely with minimal restrictions.
Quickstart
import rootutils
root = rootutils.setup_root(__file__, dotenv=True, pythonpath=True, cwd=False)
# Now import modules relative to root and access files via root / "path"
Requires Python 3.7.0 or later; python-dotenv must be installed as a runtime dependency.
Verify before relying
- Whether the package correctly handles edge cases (symlinks, monorepos, nested .git directories).
- Performance impact of recursive directory searches in large project hierarchies.
- Compatibility with virtual environments and containerized workflows.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.7.0) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — python-dotenv |
| Maintenance | actively maintained — 1,183 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 222,453/month — #9,264 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: rootutils-1.0.7-py3-none-any.whl
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pyrootutilsFinds your project root directory and…
permissive · top 5,000 on PyPI
rootpathDetects a Python project or package root…
permissive · top 15,000 on PyPI
pytest-pythonpathAdds directories to Python's import path before…
permissive · top 15,000 on PyPI
dotenvLoads environment variables from a .env file…
unclear · top 5,000 on PyPI
pyprojrootFinds your project's root directory and…
permissive · top 15,000 on PyPI
load-dotenvAutomatically loads environment variables from…
permissive · top 15,000 on PyPI
django-dotenvLoads environment variables from a .env file…
permissive · top 15,000 on PyPI
xdg-base-dirsProvides functions to retrieve XDG Base…
permissive · top 15,000 on PyPI
acresAcres provides a consistent, scoped interface…
permissive · top 15,000 on PyPI
python-dotenvReads key-value pairs from a .env file and sets…
permissive · top 100 on PyPI