Closed
Description
Environment: Windows 7, Python 2.7, Most recent Cygwin x86 (DLL 2.2.1-1)
OK. So I got python-magic running only after moving the Cygwin PATH to the beginning of the %PATH% env.var. :
1. Install the cygwin-libmagic in Cygwin
2. Install https://github.com/ahupp/python-magic (python setup.py install)
3. Place c:\cygwin\bin\ right at the beginning of PATH env.var.
4. Open python, import magic
Without the step 3 I got:
>>> import magic
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\magic.py", line 184, in <module>
raise ImportError('failed to find libmagic. Check your installation')
ImportError: failed to find libmagic. Check your installation
and:
>>> import ctypes
>>> import ctypes.util
>>> print ctypes.util.find_library('cygmagic-1')
None
>>> print ctypes.util.find_library('c')
msvcr90.dll
It looks like the find_library() method can’t be bothered to look for the libs in other places from the %PATH%. The dll it finds is in a Webex folder...
Once I've put c:\cygwin\bin at the beginning of %PATH%, all my life problems were immediately solved :
>>> import ctypes.util
>>> ctypes.util.find_library('cygmagic-1')
'c:\\cygwin\\bin\\cygmagic-1.dll'
>>> import os
>>> os.getenv("PATH")
'c:\\cygwin\\bin\\;C:\\Python27\\;C:\\Python27\\Scripts; <snip>
So I wanted to check if it really was causing the problem, moved the path to Cygwin back to the end of %PATH%, rerun cmd and opened python console, and guess what ? It still works ! Why ? :
>>> import ctypes.util
>>> ctypes.util.find_library('cygmagic-1')
'c:\\cygwin\\bin\\cygmagic-1.dll'
>>> import os
>>> os.getenv("PATH")
<snap>;C:\\Program Files (x86)\\gnuplot\\bin;c:\\cygwin\\bin'
Metadata
Metadata
Assignees
Labels
No labels