Python Forum
libmagic library issue - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: libmagic library issue (/thread-14070.html)



libmagic library issue - Sudhakar - Nov-13-2018

have installed python 2.7.15 (32 bit) on windows 2012 R2 -64 bit server. we have installed elastalert which install magic & liblogic modules. when I run the elastalert process , its giving following error.

Error:
import magic File "D:\Python27\Lib\site-packages\magic.py", line 181, in <module> raise ImportError('failed to find libmagic. Check your installation') ImportError: failed to find libmagic. Check your installation
got something in google and copied files from https://github.com/pidydx/libmagicwin64 and placed into c:\windows\system32 folder. still getting same error.

the mail problem I see is python is not finding the copied dlls
>>> os.path.exists("C:\\Windows\\syswow64\\magic1.dll")
False
if I copy these files to C:\windows\syswow64 folder, python is able to find the file from system32.

>>> os.path.exists("C:\\Windows\\syswow64\\magic1.dll")
True
>>> ctypes.util.find_library('magic1')
'C:\\Windows\\system32\\magic1.dll'
when I run the import magic, its giving following error
>>> import magic
Error:
Traceback (most recent call last): File "<pyshell#63>", line 1, in <module> import magic File "D:\Python27\Lib\site-packages\magic.py", line 159, in <module> libmagic = ctypes.CDLL(dll) File "D:\Python27\Lib\ctypes\__init__.py", line 366, in __init__ self._handle = _dlopen(self._name, mode) WindowsError: [Error 193] %1 is not a valid Win32 application
Can anyone please suggest?