我有这个从图像中读取条形码的脚本。
from PIL import Image
import zbar
scanner = zbar.ImageScanner()
scanner.parse_config('enable')
pil = Image.open('zbartest2.png').convert('L')
width, height = pil.size
raw = pil.tostring()
image = zbar.Image(width, height, 'Y800', raw)
scanner.scan(image)
for symbol in image:
print 'decoded', symbol.type, 'symbol', '"%s"' % symbol.data
del(image)
当我将此脚本放在 python 主目录中时,C:\Python27
它可以正常工作。
C:\myscript
但是,当我将此脚本放在主目录之外时,例如import zbar - module The specified module could not be found
.
是什么导致了问题?
我在 Windows Xp 32bits SP3 上使用 Python 2.7 32bits
编辑:
我正在使用运行模块命令(F5)从空闲窗口执行它;完整的回溯
Traceback (most recent call last):
File "C:\myscript\test.py", line 2, in <module>
import zbar
ImportError: DLL load failed: The specified module could not be found.
当我输入时,import zbar; print zbar.__file__
我得到以下消息
C:\Python27\lib\site-packages\zbar.pyd