我有这个脚本从图像中读取条形码。脚本只适用于Python安装目录
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)
当我主目录是C:\Python27
它工作没有任何问题,把这个脚本蟒。
但是,当我把这个脚本以外的主目录,如C:\myscript
,它给了我错误说,import zbar - module The specified module could not be found
。
是什么导致了这个问题?
我使用的Windows XP 32位SP3的Python 2.7 32位
编辑:
我从IDLE窗口通过使用运行模块命令(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
什么是* full *回溯(即复制/粘贴打印到命令提示符的所有内容)?你如何执行这个脚本? – Blender
如果你在'c:\ python27'运行下面的命令,你会得到什么:'import zbar;打印zbar .__ file__'? – falsetru
哪个模块?你得到了什么确切的错误? – 2013-12-16 03:57:31