python-magic WindowsError: access violation writing 0x00000000
python-magic WindowsError: access violation writing 0x00000000
我使用 pip 在我的 Win 7 64 位上安装了 python-magic (0.4.6)。
然后我安装了 cygwin 1.7.33-2 以提供所需的 dll 并创建了一个名为 magic1.dll 的 cygmagic-1.dll 副本(参见
当我 运行 Python 2.7.6 32 位 shell 时,"import magic" 工作正常。
然而,
magic.from_file('c:\user\username\sample.txt')
给我一个
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\Python27\lib\site-packages\magic.py", line 119, in from_file
m = _get_magic_type(mime)
File "c:\Python27\lib\site-packages\magic.py", line 107, in _get_magic_type
i = instances.__dict__[mime] = Magic(mime=mime)
File "c:\Python27\lib\site-packages\magic.py", line 55, in __init__
self.cookie = magic_open(flags)
WindowsError: exception: access violation writing 0x00000000
知道导致此错误的原因以及如何修复它吗?
感谢您的帮助!
GnuWin32 file package 有一个 32 位 magic1.dll,以及它的依赖项 regex2.dll 和 zlib1.dll。我从测试中知道这个版本适用于 python-magic。下面是我在 32 位 Python 3.3.
中测试它所采取的步骤的概述
将文件解压到 GnuWin32 的安装目录:
C:\Temp>set "GNU=C:\Program Files (x86)\GNU"
C:\Temp>7z x -y -o"%GNU%" file-5.03-bin.zip > nul
C:\Temp>7z x -y -o"%GNU%" file-5.03-dep.zip > nul
设置环境以查找 DLL 和魔术文件:
C:\Temp>set PATH=%PATH%;%GNU%\bin
C:\Temp>set MAGIC=%GNU%\share\misc\magic
安装python-magic:
C:\Temp>py -3.3-32 -m pip install python-magic
Collecting python-magic
Downloading python-magic-0.4.6.tar.gz
Installing collected packages: python-magic
Running setup.py install for python-magic
Successfully installed python-magic-0.4.6
验证它是否有效:
C:\Temp>py -3.3-32
Python 3.3.5 (v3.3.5:62cf4e77f785, Mar 9 2014, 10:37:12)
[MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys, magic
>>> magic.from_file(sys.executable)
b'PE32 executable for MS Windows (console) Intel 80386 32-bit'
我使用 pip 在我的 Win 7 64 位上安装了 python-magic (0.4.6)。 然后我安装了 cygwin 1.7.33-2 以提供所需的 dll 并创建了一个名为 magic1.dll 的 cygmagic-1.dll 副本(参见
当我 运行 Python 2.7.6 32 位 shell 时,"import magic" 工作正常。
然而,
magic.from_file('c:\user\username\sample.txt')
给我一个
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\Python27\lib\site-packages\magic.py", line 119, in from_file
m = _get_magic_type(mime)
File "c:\Python27\lib\site-packages\magic.py", line 107, in _get_magic_type
i = instances.__dict__[mime] = Magic(mime=mime)
File "c:\Python27\lib\site-packages\magic.py", line 55, in __init__
self.cookie = magic_open(flags)
WindowsError: exception: access violation writing 0x00000000
知道导致此错误的原因以及如何修复它吗? 感谢您的帮助!
GnuWin32 file package 有一个 32 位 magic1.dll,以及它的依赖项 regex2.dll 和 zlib1.dll。我从测试中知道这个版本适用于 python-magic。下面是我在 32 位 Python 3.3.
中测试它所采取的步骤的概述将文件解压到 GnuWin32 的安装目录:
C:\Temp>set "GNU=C:\Program Files (x86)\GNU"
C:\Temp>7z x -y -o"%GNU%" file-5.03-bin.zip > nul
C:\Temp>7z x -y -o"%GNU%" file-5.03-dep.zip > nul
设置环境以查找 DLL 和魔术文件:
C:\Temp>set PATH=%PATH%;%GNU%\bin
C:\Temp>set MAGIC=%GNU%\share\misc\magic
安装python-magic:
C:\Temp>py -3.3-32 -m pip install python-magic
Collecting python-magic
Downloading python-magic-0.4.6.tar.gz
Installing collected packages: python-magic
Running setup.py install for python-magic
Successfully installed python-magic-0.4.6
验证它是否有效:
C:\Temp>py -3.3-32
Python 3.3.5 (v3.3.5:62cf4e77f785, Mar 9 2014, 10:37:12)
[MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys, magic
>>> magic.from_file(sys.executable)
b'PE32 executable for MS Windows (console) Intel 80386 32-bit'