我正在使用 python 的 elaphe 包来生成 ean-13 条形码图像。该软件包是使用位于https://pypi.python.org/pypi/elaphe的 tar 文件从源代码安装的。
当我运行代码时:
BARCODE_IMAGE_PATH = "/tmp/"
def create_barcode_image(product_barcode):
path = BARCODE_IMAGE_PATH + product_barcode + '.png'
img = barcode('ean13', product_barcode,
options=dict(includetext=True, height=0.4), margin=1)
img.save(path, 'PNG')
return path
从 python 解释器看来,它似乎工作得很好。正确的条形码生成到我指定的路径。当我使用 web.py 作为我的 web 框架从 apache 运行它时,我收到错误:
Traceback (most recent call last):
...
img_path = create_barcode_image(barcode)
File "/var/www/py/documents/barcode_images.py", line 27, in create_barcode_image
img.save(path, 'PNG')
File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 1406, in save
self.load()
File "/usr/local/lib/python2.7/dist-packages/PIL/EpsImagePlugin.py", line 283, in load
self.im = Ghostscript(self.tile, self.size, self.fp)
File "/usr/local/lib/python2.7/dist-packages/PIL/EpsImagePlugin.py", line 75, in Ghostscript
raise IOError("gs failed (status %d)" % status)
IOError: gs failed (status 256)
有谁知道可能导致此错误的原因或如何调试它?