0

In my Python code I use yara to compile yara rules.

The documentation located at https://yara.readthedocs.io/en/stable/yarapython.html says that I can use it by importing it like this:

import yara

However when I run the code I get

FileNotFoundError: Could not find module 'C:\Users\bruker\Pycharmprojects\projectx\venv\DLLs\libyara.dll' (or one of its dependencies). Try using the full path with constructor syntax.

I am using a venv python enviroment for this project running in Windows 11.

I have tried the following:

  • pip install yara
  • pip install --upgrade --force-reinstall yara
  • pip install -I yara
  • pip install --ignore-installed yara

However I still get that the libyara.dll file is missing:

Traceback (most recent call last):
  File "C:\Users\bruker\Pycharmprojects\projectx\deploygate.py", line 14, in <module>
    import yara
  File "C:\Users\bruker\Pycharmprojects\projectx\venv\lib\site-packages\yara\__init__.py", line 7, in <module>
    from yara.rules import compile
  File "C:\Users\bruker\Pycharmprojects\projectx\venv\lib\site-packages\yara\rules.py", line 17, in <module>
    from yara.libyara_wrapper import *
  File "C:\Users\bruker\Pycharmprojects\projectx\venv\lib\site-packages\yara\libyara_wrapper.py", line 315, in <module>
    libyaradll = cdll.LoadLibrary(library)
  File "C:\Users\bruker\AppData\Local\Programs\Python\Python310\lib\ctypes\__init__.py", line 452, in LoadLibrary
    return self._dlltype(name)
  File "C:\Users\bruker\AppData\Local\Programs\Python\Python310\lib\ctypes\__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'C:\Users\bruker\Pycharmprojects\projectx\venv\DLLs\libyara.dll' (or one of its dependencies). Try using the full path with constructor syntax.

How can I fix the yara dll file missing? I am using Python 3.10.

Europa
  • 974
  • 12
  • 40
  • 1
    Did you [follow the Windows installation steps](https://yara.readthedocs.io/en/stable/gettingstarted.html#installing-on-windows)? – AKX Sep 22 '22 at 10:23
  • Yes, I've downloaded the Windows binaries and have runned "choco install yara". But the dll file is still missing from the DLL file. – Europa Sep 22 '22 at 11:17

0 Answers0