skillfed

yara-python

Python interface for YARA

yara-python v4.5.4 1.8M downloads/30d#3,549 on PyPI751
Permissive license Apache 2.0 Active released

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-python

uv

uv add yara-python

poetry

poetry add yara-python

Installing 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

Development Status :: 5 - Production/StableLicense :: OSI Approved :: Apache Software LicenseOperating System :: OS IndependentProgramming Language :: Python

Tags

pattern matching malware detectionyara rule compilation pythonstring scanning and matchingfile content pattern rulesregex-like rule engine
malware-detectionpattern-matchingsecurity-scanning

More Security packages