{"id":8559,"library":"python-ripgrep","title":"Python Ripgrep","description":"python-ripgrep is a Python wrapper for the high-performance ripgrep command-line utility. It provides a programmatic interface to run ripgrep searches, parse results, and interact with its various options. Currently at version 0.0.9, its release cadence is irregular, with updates typically occurring to add new features or align with upstream ripgrep changes.","status":"active","version":"0.0.9","language":"python","source_language":"en","source_url":"https://github.com/PyO3/python-ripgrep","tags":["search","ripgrep","cli-wrapper","regex","performance"],"install":[{"cmd":"pip install python-ripgrep","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"The library is a wrapper around the ripgrep CLI tool, which must be installed separately and available in the system's PATH.","package":"ripgrep (executable)","optional":false}],"imports":[{"wrong":"from python_ripgrep import Ripgrep","symbol":"search","correct":"from python_ripgrep import search"},{"symbol":"files","correct":"from python_ripgrep import files"},{"symbol":"PySortMode","correct":"from python_ripgrep import PySortMode"}],"quickstart":{"code":"import os\nfrom python_ripgrep import Ripgrep\n\n# Ensure ripgrep is installed and in your PATH.\n# For example:\n# Debian/Ubuntu: sudo apt install ripgrep\n# macOS (Homebrew): brew install ripgrep\n# Rust cargo: cargo install ripgrep\n\n# Create a dummy file for searching if it doesn't exist\nif not os.path.exists(\"example_rg.txt\"):\n    with open(\"example_rg.txt\", \"w\") as f:\n        f.write(\"Hello, World!\\n\")\n        f.write(\"This is a test line.\\n\")\n        f.write(\"Another line with 'World'.\\n\")\n        f.write(\"hello world again.\\n\")\n\ntry:\n    # Initialize Ripgrep instance, searching in the current directory\n    # You can also specify a different path: rg = Ripgrep(path='/path/to/project')\n    rg = Ripgrep(path='.')\n\n    # Perform a case-insensitive search for \"world\" in .txt files\n    # The search method returns an iterator over results\n    print(\"Searching for 'world' (case-insensitive) in .txt files:\")\n    results = rg.search('world', file_type='.txt', ignorecase=True)\n\n    found_results = False\n    for result in results:\n        found_results = True\n        print(f\"File: {result.file}, Line: {result.line_number}, Match: '{result.match}'\")\n\n    if not found_results:\n        print(\"No results found.\")\n\nexcept FileNotFoundError as e:\n    if \"No such file or directory: 'rg'\" in str(e):\n        print(\"\\nERROR: ripgrep executable 'rg' not found in your PATH.\")\n        print(\"Please install ripgrep from: https://github.com/BurntSushi/ripgrep#installation\")\n    else:\n        print(f\"\\nAn unexpected FileNotFoundError occurred: {e}\")\nexcept Exception as e:\n    print(f\"\\nAn error occurred: {e}\")\n\nfinally:\n    # Clean up the dummy file\n    if os.path.exists(\"example_rg.txt\"):\n        os.remove(\"example_rg.txt\")","lang":"python","description":"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."},"warnings":[{"fix":"Ensure `ripgrep` is installed (e.g., `sudo apt install ripgrep`, `brew install ripgrep`, or `cargo install ripgrep`) and its executable (`rg`) is accessible from your system's PATH.","message":"The `python-ripgrep` library is merely a wrapper; it does not bundle the `ripgrep` executable. `ripgrep` must be installed separately on your system and available in the system's PATH.","severity":"gotcha","affected_versions":"All versions"},{"fix":"When updating, always review the GitHub repository's changelog or commit history for any API changes. Pin your dependency to a specific `0.0.x` version if stability is critical.","message":"As a pre-1.0 library (0.0.x), the API of `python-ripgrep` may undergo breaking changes in minor versions without explicit deprecation warnings.","severity":"gotcha","affected_versions":"<1.0.0"},{"fix":"Process `results` iteratively using a `for` loop to avoid loading all matches into memory simultaneously. If you need to paginate or limit results, consider implementing logic around the iterator or using `ripgrep`'s inherent `--max-count` option via the wrapper.","message":"For very large search results, loading all results into memory at once can consume significant resources. The `search` method returns an iterator.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'0.0.9':40 'add':51 'align':55 'cadenc':43 'chang':59 'cli':63 'cli-wrapp':62 'command':17 'command-lin':16 'current':37 'featur':53 'high':13 'high-perform':12 'interact':32 'interfac':24 'irregular':45 'line':18 'new':52 'occur':49 'option':36 'pars':29 'perform':14,66 'programmat':23 'provid':21 'python':1,4,8 'python-ripgrep':3 'regex':65 'releas':42 'result':30 'ripgrep':2,5,15,27,58,61 'run':26 'search':28,60 'typic':48 'updat':47 'upstream':57 'util':19 'various':35 'version':39 'wrapper':9,64","created_at":"2026-04-16T17:02:48.662065+00:00","updated_at":"2026-04-16T17:02:48.662065+00:00","problems":null,"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.0.9","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/python-ripgrep/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking","devops","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-30","last_verified":"2026-06-30","next_check":"2026-07-30","install_tag":null}}