skillfed

rootutils

Simple package for easy project root setup

rootutils v1.0.7 222.5K downloads/30d#9,264 on PyPI180
Permissive license MIT Active released

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 rootutils

uv

uv add rootutils

poetry

poetry add rootutils

Installing 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

project root finderpythonpath setupworking directory managementrelative imports from project rootenvironment variable loader.env file loaderpython path configuration
path-managementproject-setup

More Utilities packages