yara-python
Python interface for YARA
What it is and what it does
yara-python is a Python binding to YARA, the pattern-matching engine developed by VirusTotal. It allows you to write rules that describe patterns in data—typically used for malware detection, log analysis, and security scanning—and then compile and execute those rules against files, strings, or process memory from Python code.
The library exposes YARA's full feature set: you define rules using YARA's domain-specific syntax (strings, conditions, tags), compile them into rule objects, and call match() to scan data. Results include the matched rule name, tags, and detailed information about each string match, including offset and matched length. No runtime dependencies are required beyond the compiled C extension.
Use it for:
- Malware detection and threat hunting by scanning files or memory against known malicious patterns
- Log analysis and security event correlation by matching structured or unstructured text against detection rules
- Content filtering and data classification by scanning strings or file contents against custom rule sets
- Incident response automation by integrating YARA scanning into Python-based security workflows
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
yara-python provides a Python interface to YARA, enabling you to compile pattern-matching rules, scan files and strings for matches, and extract detailed information about what was matched.
Yes. yara-python is actively maintained, has no known vulnerabilities, carries a permissive license, and offers pre-built wheels for common platforms. Install friction is moderate but manageable. It is the standard way to use YARA from Python and is well-suited for security, malware analysis, and pattern-matching workflows.
Install
yara-python on PyPI
pip
pip install yara-pythonuv
uv add yara-pythonpoetry
poetry add yara-pythonInstalling yara-python
Before you install
Medium install friction due to compiled C extension bindings; pre-built wheels are available for common platforms (macOS, Linux, Windows across multiple architectures), but dynamic linking requires building YARA separately. Last release was 444 days ago; repository is active with recent commits.
License in practice
Apache 2.0 permissive license allows commercial use, modification, and distribution with minimal restrictions—suitable for most projects.
Quickstart
pip install yara-python
import yara
rule = yara.compile(source='rule foo: bar {strings: $a = "lmn" condition: $a}')
matches = rule.match(data='abcdefgjiklmnoprstuvwxyz')
print(matches[0].rule, matches[0].strings)
Pre-built wheels are available for common platforms; if using dynamic linking, YARA must be built and installed separately before installing yara-python.
Verify before relying
- Whether Python version support is documented beyond the unspecified classifier
- Performance characteristics for large-scale scanning or complex rule sets
Package facts
| License | Apache 2.0 (permissive) |
| Python support | not specified |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 444 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,796,639/month — #3,549 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: yara_python-4.5.4-cp310-cp310-macosx_14_0_arm64.whl; yara_python-4.5.4-cp310-cp310-macosx_14_0_x86_64.whl; yara_python-4.5.4-cp310-cp310-macosx_15_0_arm64.whl; yara_python-4.5.4-cp310-cp310-macosx_15_0_x86_64.whl; yara_python-4.5.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; yara_python-4.5.4-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl; yara_python-4.5.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; yara_python-4.5.4-cp310-cp310-musllinux_1_2_aarch64.whl; yara_python-4.5.4-cp310-cp310-musllinux_1_2_i686.whl; yara_python-4.5.4-cp310-cp310-musllinux_1_2_x86_64.whl; yara_python-4.5.4-cp310-cp310-win32.whl; yara_python-4.5.4-cp310-cp310-win_amd64.whl; yara_python-4.5.4-cp311-cp311-macosx_14_0_arm64.whl; yara_python-4.5.4-cp311-cp311-macosx_14_0_x86_64.whl; yara_python-4.5.4-cp311-cp311-macosx_15_0_arm64.whl; yara_python-4.5.4-cp311-cp311-macosx_15_0_x86_64.whl; yara_python-4.5.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; yara_python-4.5.4-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl; yara_python-4.5.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; yara_python-4.5.4-cp311-cp311-musllinux_1_2_aarch64.whl
Tags
More Security packages
Provides Python bindings to the FreeDesktop.org…
permissive · top 1,000 on PyPI
msalMSAL for Python handles OAuth2 and OpenID…
permissive · top 1,000 on PyPI
joserfcjoserfc implements JOSE standards (JWS, JWE,…
permissive · top 1,000 on PyPI
AuthlibAuthlib provides a complete implementation of…
permissive · top 1,000 on PyPI
argon2-cffi-bindingsProvides low-level CFFI bindings to the…
permissive · top 1,000 on PyPI
adalADAL for Python authenticates applications with…
permissive · top 1,000 on PyPI
plyaraParses YARA rule files into Python dictionary…
permissive · top 15,000 on PyPI
yara-xPython bindings for YARA-X, a pattern-matching…
permissive · top 15,000 on PyPI
cisco-ai-mcp-scannerScans MCP (Model Context Protocol) servers and…
unclear · top 15,000 on PyPI
gitignorantParses .gitignore files and matches file paths…
permissive · top 15,000 on PyPI
PyMeta3PyMeta3 compiles pattern-matching grammars…
permissive · top 15,000 on PyPI
rule-engineRule Engine provides a lightweight, custom…
permissive · top 15,000 on PyPI
cisco-ai-skill-scannerScans AI Agent Skills for prompt injection,…
permissive · top 15,000 on PyPI
gitignorefileParses `.gitignore` files according to Git's…
permissive · top 15,000 on PyPI
virustotal3Provides a Python 3 client library for the…
unclear · top 15,000 on PyPI
ParsleyParsley is a PEG-based parsing library that…
permissive · top 5,000 on PyPI