我是python中的新手,我正在研究一个需要检测文件类型的项目,所以我使用了魔法库,但代码不起作用,它引发了异常。 测试代码是:
import magic
magic.from_file("./example.db")
追溯:
Traceback (most recent call last):
- File "C:\Users\mariam\Desktop\pythonscripto\test.py", line 4, in <module>
magic.from_file("./example.db")
- File "C:\Users\mariam\Desktop\pythonscripto\magic.py", line 122, in from_file
m = _get_magic_type(mime)
- File "C:\Users\mariam\Desktop\pythonscripto\magic.py", line 111, in _get_magic_type
i = _instances[mime] = Magic(mime=mime)
- File "C:\Users\mariam\Desktop\pythonscripto\magic.py", line 60, in \__init__
magic_load(self.cookie, magic_file)
- File "C:\Users\mariam\Desktop\pythonscripto\magic.py", line 250, in magic_load
return _magic_load(cookie, coerce_filename(filename))
- File "C:\Users\mariam\Desktop\pythonscripto\magic.py", line 181, in errorcheck_negative_one
raise MagicException(err)
magic.MagicException: None
任何帮助?
答案 0 :(得分:1)
我解决了这个问题,只确保你的Python版本是64位,以及依赖文件,你应该在同一个文件夹中包含以下文件: