Install & Compatibility
Where this runs
tested against v0.0.9 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 22.9MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 1.6s · import 0.000s · 23MB
21MB installed
● package 21MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
search
✓ from python_ripgrep import search
✗ from python_ripgrep import Ripgrep
files
✓ from python_ripgrep import files
PySortMode
✓ from python_ripgrep import PySortMode
This quickstart demonstrates how to initialize the Ripgrep wrapper and perform a basic case-insensitive search for a term in text files. It includes setup for a dummy file and error handling for the missing `ripgrep` executable.
import os
from python_ripgrep import Ripgrep
# Ensure ripgrep is installed and in your PATH.
# For example:
# Debian/Ubuntu: sudo apt install ripgrep
# macOS (Homebrew): brew install ripgrep
# Rust cargo: cargo install ripgrep
# Create a dummy file for searching if it doesn't exist
if not os.path.exists("example_rg.txt"):
with open("example_rg.txt", "w") as f:
f.write("Hello, World!\n")
f.write("This is a test line.\n")
f.write("Another line with 'World'.\n")
f.write("hello world again.\n")
try:
# Initialize Ripgrep instance, searching in the current directory
# You can also specify a different path: rg = Ripgrep(path='/path/to/project')
rg = Ripgrep(path='.')
# Perform a case-insensitive search for "world" in .txt files
# The search method returns an iterator over results
print("Searching for 'world' (case-insensitive) in .txt files:")
results = rg.search('world', file_type='.txt', ignorecase=True)
found_results = False
for result in results:
found_results = True
print(f"File: {result.file}, Line: {result.line_number}, Match: '{result.match}'")
if not found_results:
print("No results found.")
except FileNotFoundError as e:
if "No such file or directory: 'rg'" in str(e):
print("\nERROR: ripgrep executable 'rg' not found in your PATH.")
print("Please install ripgrep from: https://github.com/BurntSushi/ripgrep#installation")
else:
print(f"\nAn unexpected FileNotFoundError occurred: {e}")
except Exception as e:
print(f"\nAn error occurred: {e}")
finally:
# Clean up the dummy file
if os.path.exists("example_rg.txt"):
os.remove("example_rg.txt")
Upgrade
Version history
0.0.9latest on PyPI · released Jul 30, 2025
Audit
Dependencies
ripgrep (executable)requiredThe library is a wrapper around the ripgrep CLI tool, which must be installed separately and available in the system's PATH.