VirusTotal / yara-python

The Python interface for YARA
http://virustotal.github.io/yara/
Apache License 2.0
646 stars 179 forks source link

Error while trying to install yara-python #202

Closed lic-8 closed 2 years ago

lic-8 commented 2 years ago

I'm on Ubuntu 18 and I try to install yara but I'm getting an error. Does anyone know how do I get this fixed ? Thanks.

user@hp-workstation:~/Documents/volatility3$ python3.7 -m pip install yara-python
Defaulting to user installation because normal site-packages is not writeable
Collecting yara-python
  Using cached yara-python-4.2.0.tar.gz (453 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: yara-python
  Building wheel for yara-python (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [24 lines of output]
      running bdist_wheel
      running build
      running build_ext
      building 'yara' extension
      creating build
      creating build/temp.linux-x86_64-3.7
      creating build/temp.linux-x86_64-3.7/yara
      creating build/temp.linux-x86_64-3.7/yara/libyara
      creating build/temp.linux-x86_64-3.7/yara/libyara/modules
      creating build/temp.linux-x86_64-3.7/yara/libyara/modules/demo
      creating build/temp.linux-x86_64-3.7/yara/libyara/modules/console
      creating build/temp.linux-x86_64-3.7/yara/libyara/modules/pe
      creating build/temp.linux-x86_64-3.7/yara/libyara/modules/hash
      creating build/temp.linux-x86_64-3.7/yara/libyara/modules/tests
      creating build/temp.linux-x86_64-3.7/yara/libyara/modules/math
      creating build/temp.linux-x86_64-3.7/yara/libyara/modules/time
      creating build/temp.linux-x86_64-3.7/yara/libyara/modules/elf
      creating build/temp.linux-x86_64-3.7/yara/libyara/proc
      x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-pX47U3/python3.7-3.7.12=. -fstack-protector-strong -Wformat -Werror=format-security -g -fdebug-prefix-map=/build/python3.7-pX47U3/python3.7-3.7.12=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -D_GNU_SOURCE=1 -DUSE_LINUX_PROC=1 -DHAVE_STDBOOL_H=1 -DHAVE_MEMMEM=1 -DHASH_MODULE=1 -DHAVE_LIBCRYPTO=1 -Iyara/libyara/include -Iyara/libyara/ -I. -I/usr/include/python3.7m -c yara-python.c -o build/temp.linux-x86_64-3.7/yara-python.o -std=c99
      yara-python.c:20:10: fatal error: Python.h: No such file or directory
       #include <Python.h>
                ^~~~~~~~~~
      compilation terminated.
      error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for yara-python
  Running setup.py clean for yara-python
Failed to build yara-python
Installing collected packages: yara-python
  Running setup.py install for yara-python ... error
  error: subprocess-exited-with-error

  × Running setup.py install for yara-python did not run successfully.
  │ exit code: 1
  ╰─> [24 lines of output]
      running install
      running build
      running build_ext
      building 'yara' extension
      creating build
      creating build/temp.linux-x86_64-3.7
      creating build/temp.linux-x86_64-3.7/yara
      creating build/temp.linux-x86_64-3.7/yara/libyara
      creating build/temp.linux-x86_64-3.7/yara/libyara/modules
      creating build/temp.linux-x86_64-3.7/yara/libyara/modules/demo
      creating build/temp.linux-x86_64-3.7/yara/libyara/modules/console
      creating build/temp.linux-x86_64-3.7/yara/libyara/modules/pe
      creating build/temp.linux-x86_64-3.7/yara/libyara/modules/hash
      creating build/temp.linux-x86_64-3.7/yara/libyara/modules/tests
      creating build/temp.linux-x86_64-3.7/yara/libyara/modules/math
      creating build/temp.linux-x86_64-3.7/yara/libyara/modules/time
      creating build/temp.linux-x86_64-3.7/yara/libyara/modules/elf
      creating build/temp.linux-x86_64-3.7/yara/libyara/proc
      x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-pX47U3/python3.7-3.7.12=. -fstack-protector-strong -Wformat -Werror=format-security -g -fdebug-prefix-map=/build/python3.7-pX47U3/python3.7-3.7.12=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -D_GNU_SOURCE=1 -DUSE_LINUX_PROC=1 -DHAVE_STDBOOL_H=1 -DHAVE_MEMMEM=1 -DHASH_MODULE=1 -DHAVE_LIBCRYPTO=1 -Iyara/libyara/include -Iyara/libyara/ -I. -I/usr/include/python3.7m -c yara-python.c -o build/temp.linux-x86_64-3.7/yara-python.o -std=c99
      yara-python.c:20:10: fatal error: Python.h: No such file or directory
       #include <Python.h>
                ^~~~~~~~~~
      compilation terminated.
      error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> yara-python

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
mgmacias95 commented 2 years ago

Hello,

It looks like you don't have python3-dev package installed. Try installing it using the following command:

$  sudo apt-get install python3-dev

I hope this helps.

Regards, Marta