VirusTotal / yara-python

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

"pip install" fails with Python 3.8 (amd64) on Windows 10 #150

Closed nmantani closed 3 years ago

nmantani commented 4 years ago

Hello,

I use Python 3.8.3 (amd64) on Windows 10. When I tried to install yara-python 4.0.2 with pip, I got the following error. I was able to successfully install it with Python 3.7.8 (amd64).

PS C:\Users\user\Desktop> py -3
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> ^Z

PS C:\Users\user\Desktop> py -3 -m pip install yara-python
Collecting yara-python
  Downloading yara-python-4.0.2.tar.gz (405 kB)
     |████████████████████████████████| 405 kB 364 kB/s
Could not build wheels for yara-python, since package 'wheel' is not installed.
Installing collected packages: yara-python
    Running setup.py install for yara-python ... error
    ERROR: Command errored out with exit status 1:
     command: 'C:\Users\user\AppData\Local\Programs\Python\Python38\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-06j662xr\\yara-python\\setup.py'"'"'; __file__='"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-06j662xr\\yara-python\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\user\AppData\Local\Temp\pip-record-kpjcfvu6\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\user\AppData\Local\Programs\Python\Python38\Include\yara-python'
         cwd: C:\Users\user\AppData\Local\Temp\pip-install-06j662xr\yara-python\
    Complete output (4 lines):
    running install
    running build
    running build_ext
    error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\user\AppData\Local\Programs\Python\Python38\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-06j662xr\\yara-python\\setup.py'"'"'; __file__='"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-06j662xr\\yara-python\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\user\AppData\Local\Temp\pip-record-kpjcfvu6\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\user\AppData\Local\Programs\Python\Python38\Include\yara-python' Check the logs for full command output.
WARNING: You are using pip version 20.1; however, version 20.1.1 is available.
You should consider upgrading via the 'C:\Users\user\AppData\Local\Programs\Python\Python38\python.exe -m pip install --upgrade pip' command.
PS C:\Users\user\Desktop>

So I tried to manually download and install the wheel file (I got the download URL from https://pypi.org/project/yara-python/#files), I got the following error.

PS C:\Users\user\Desktop> curl -o yara_python-4.0.2-cp38-cp38m-win_amd64.whl  https://files.pythonhosted.org/packages/a1/f4/572ec37bca6019d6666351f36a3809d4c46510e2c9c3a3f8ac4c7f670704/yara_python-4.0.2-cp38-cp38m-win_amd64.whl
PS C:\Users\user\Desktop> py -3 -m pip install .\yara_python-4.0.2-cp38-cp38m-win_amd64.whl
ERROR: yara_python-4.0.2-cp38-cp38m-win_amd64.whl is not a supported wheel on this platform.
WARNING: You are using pip version 20.1; however, version 20.1.1 is available.
You should consider upgrading via the 'C:\Users\user\AppData\Local\Programs\Python\Python38\python.exe -m pip install --upgrade pip' command.
PS C:\Users\user\Desktop>

Finally I was able to install the wheel file by renaming it ("cp38m" -> "cp38").

PS C:\Users\user\Desktop> Move-Item .\yara_python-4.0.2-cp38-cp38m-win_amd64.whl .\yara_python-4.0.2-cp38-cp38-win_amd64.whl
PS C:\Users\user\Desktop> py -3 -m pip install .\yara_python-4.0.2-cp38-cp38-win_amd64.whl
Processing c:\users\user\desktop\yara_python-4.0.2-cp38-cp38-win_amd64.whl
Installing collected packages: yara-python
Successfully installed yara-python-4.0.2
WARNING: You are using pip version 20.1; however, version 20.1.1 is available.
You should consider upgrading via the 'C:\Users\user\AppData\Local\Programs\Python\Python38\python.exe -m pip install --upgrade pip' command.
PS C:\Users\user\Desktop> py -3
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import yara
>>> ^Z

PS C:\Users\user\Desktop>

A similar issue of Coverage.py: https://github.com/nedbat/coveragepy/issues/949

This change in Python 3.8 may be related to the error: https://docs.python.org/dev/whatsnew/3.8.html#build-and-c-api-changes

Building yara-python wheel files with a newer version of wheel may fix the error. https://github.com/pypa/wheel/pull/303

I use yara-python in my malware analysis tool FileInsight-plugins (https://github.com/nmantani/FileInsight-plugins/) to use YARA in McAfee FileInsight hex editor. Thank you very much for developing!

JhonJohnatan commented 3 years ago

+1

nmantani commented 3 years ago

Hello,

Thank you for updating wheel files at pypi.org to 4.0.3. However, the error that I reported is not fixed yet. The wheel file name for Python 3.8 should be yara_python-4.0.3-cp38-cp38-win_amd64.whl (please change "cp38m" to "cp38") .

plusvic commented 3 years ago

Fixed in 4.0.4

nmantani commented 3 years ago

Thank you so much!