trendmicro / tlsh

Other
726 stars 135 forks source link

Unable to install tlsh (Fatal Error C1083) #94

Closed DWetherilt closed 3 years ago

DWetherilt commented 3 years ago

I have tried to install using pip and I get an error saying "Cannot open include file WinFunctions.h : No such file or directory"

I'm using windows server with python 3.9 and pywin. MSVC++ build tools 14 is installed and I am issuing the command "pip install python-tlsh" to trigger the installation. My Path variables point to the base python folder, the scripts folder and the include folder.

I'm guessing I'm missing something obvious, but would appreciate any pointers.

Thank you!

jonjoliver commented 3 years ago

We are not in charge of the pip installer. But I will try to help. Let me see about this.

DWetherilt commented 3 years ago

Thank you, I appreciate you taking the time to have a quick look for me!

Windows Server 2019 python 3.9.0 pywin 32 300

jonjoliver commented 3 years ago

I am a linux / Mac programmer - so I am going to have to work through this. But I think it is important that I get TLSH working well on Windows in Python. (I was able to use minGW to get it all compiling on Windows - and made tlsh.exe available) I have set up Azure account - and got Windows Server 2019 instance set up.

Could you please point me to the same websites you used for installing Python 3.9 and pywin 32 300? That will maximise the chance that we fix this all up... :-)

jonjoliver commented 3 years ago

Ok - I have tried

py -m pip install python-tlsh I did this without the wheel package and with the wheel package. Both failed.

I get the same as you: include\tlsh.h(117): fatal error C1083: Cannot open include file: 'WinFunctions.h': No such file or directory

It appears that the python-tlsh package may be broken for windows... I will try to find out who owns this package - and get it fixed.

In the meantime, I will try to figure out another way to get tlsh working in python on Windows

DWetherilt commented 3 years ago

Thanks for confirming my suspicions and appreciate you taking the time to help me.

DWetherilt commented 3 years ago

@jonjoliver: Did you manage to flag this with the package maintainer at all?

jonjoliver commented 3 years ago

I have set up a new python repo called py-tlsh I have done the minimum changes that appears to fix Windows @DWetherilt could yes test for your environment. This works on my windows server 2019 instance in Azure.

py -m pip install -i https://test.pypi.org/simple/ py-tlsh

If that works - then I will bring this library up to date

DWetherilt commented 3 years ago

Oh wow, thanks for digging in to that. I’ve put some time aside on Monday to test this. I’ll report back here with my results.

DWetherilt commented 3 years ago

I couldn't wait until Monday, so found some time tonight to give this a quick try so I can get an answer to you. That package installed perfectly and I have made a quick script importing tlsh and performed a quick hash and comparison routine which worked as expected.

jonjoliver commented 3 years ago

I have set up the package py-tlsh on pypi.org You can see it at https://pypi.org/project/py-tlsh/ This works on Windows and has other improvements. You can install it by $ pip install py-tlsh

jonjoliver commented 3 years ago

with the creation of py-tlsh package on PyPi.org this issue should be resolved

KiaraR commented 1 year ago

I have same issue, i am also working in Windows and pip3 install py-tlsh also doesnt work..

mik1232 commented 1 year ago

Hello @jonjoliver , thank you for your efforts. I have some issues with installing tlsh both with pip install py-tlsh and pip install python-tlsh, I already installed Visual Studio, enabled C++ Build tools and both with Pycharm and with the command prompt in windows (run as admin) i get this error:

Collecting py-tlsh
  Using cached py-tlsh-4.7.2.tar.gz (42 kB)
  Preparing metadata (setup.py) ... done
Installing collected packages: py-tlsh
  DEPRECATION: py-tlsh is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
  Running setup.py install for py-tlsh ... error
  error: subprocess-exited-with-error

  × Running setup.py install for py-tlsh did not run successfully.
  │ exit code: 1
  ╰─> [7 lines of output]
      running install
      C:\Users\myname\AppData\Local\Programs\Python\Python311\Lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_ext
      building 'tlsh' extension
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [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.
╰─> py-tlsh

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

C:\Windows\System32>pip install python-tlsh
Collecting python-tlsh
  Using cached python-tlsh-4.5.0.tar.gz (40 kB)
  Preparing metadata (setup.py) ... done
Installing collected packages: python-tlsh
  DEPRECATION: python-tlsh is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
  Running setup.py install for python-tlsh ... error
  error: subprocess-exited-with-error

  × Running setup.py install for python-tlsh did not run successfully.
  │ exit code: 1
  ╰─> [7 lines of output]
      running install
      C:\Users\myname\AppData\Local\Programs\Python\Python311\Lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_ext
      building 'tlsh' extension
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [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.
╰─> python-tlsh

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