在 Windows XP 上使用 python magic 的错误消息



我按照这里的说明操作...

https://github.com/ahupp/python-magic#dependencies

我运行了pip安装python-magic,它安装没有任何问题。 然后我安装了cygwin并将C:\cygwin\bin添加到我的系统路径中。 当我在 Windows 命令提示符下运行 python 解释器并导入魔法时,我收到此错误......

Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import magic
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:Python27libsite-packagesmagic.py", line 161, in <module>
raise ImportError('failed to find libmagic.  Check your installation')
ImportError: failed to find libmagic.  Check your installation
>>>

我错过了一步吗?

python-magic使用libmagic

libmagic需要magic1.dll

magic1.dllgnuwin32的文件包中。

解决方案 1:

下载binaries zipsetup文件包,并将其目录bin路径添加到PATH环境变量中。

解决方案 2:

python-magic代码中还有一个新的更改集可以解决问题,您无需归档gnuwin32包(只需将cygwin目录添加到PATHbin),但目前还没有magic.py,而您使用pip install python-magicpip install python-magic --upgrade安装它,
因此,您需要从主安装python-magic

也看看这篇文章:http://www.thehackeruniversity.com/2014/02/02/obtain-python-mime-types-windows/

这家伙使用 Hachoir 来查找二进制文件的 mime 信息。

相关内容

最新更新