Skip to main content

Python interface for YARA

Project description


With this library you can use YARA from your Python programs. It covers all YARA’s features, from compiling, saving and loading rules to scanning files, strings and processes.

Here it goes a little example:

>>> import yara
>>> rule = yara.compile(source='rule foo: bar {strings: $a = "lmn" condition: $a}')
>>> matches = rule.match(data='abcdefgjiklmnoprstuvwxyz')
>>> print(matches)
>>> print(matches[0].rule)
>>> print(matches[0].tags)
>>> print(matches[0].strings)
[(10L, '$a', 'lmn')]


The easiest way of installing YARA is by using pip:

$ pip install yara-python

But you can also get the source from GitHub and compile it yourself:

$ git clone --recursive
$ cd yara-python
$ python build
$ sudo python install

Notice the --recursive option used with git. This is important because we need to download the yara subproject containing the source code for libyara (the core YARA library). It’s also important to note that the two methods above link libyara statically into yara-python. If you want to link dynamically against a shared libyara library use:

$ sudo python install --dynamic-linking

For this option to work you must build and install YARA separately before installing yara-python.


Find more information about how to use yara-python at

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for ak-yara-python, version 3.11.0
Filename, size File type Python version Upload date Hashes
Filename, size ak_yara_python-3.11.0-cp36-cp36m-manylinux1_x86_64.whl (593.3 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size ak_yara_python-3.11.0-cp37-cp37m-manylinux1_x86_64.whl (594.5 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size ak_yara_python-3.11.0-cp38-cp38-macosx_10_14_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (186.0 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size ak_yara_python-3.11.0-cp38-cp38-manylinux1_x86_64.whl (595.7 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size ak-yara-python-3.11.0.tar.gz (376.2 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page