I would like to use Elaphe to generate barcodes.
I am getting gs failed errors when I run the example codes.
I am working on a 64-bit windows machine. I have python 2.7.1 for win32 installed because win32 was required for certain packages. SO, I installed Ghostscript 9.0.4 win 32. I added the correct path to the PATH variable.
I installed elaphe, the python imaging library, and the python ghostscript 0.41 egg using easy_install (not sure if this was necessary).
I can import elaphe and PIL into python and execute commands without error. Whenever I try to save the barcodes as images I get errors.
When I run this simple usage example:
>>> from elaphe import barcode
>>> barcode('qrcode',
... 'Hello Barcode Writer In Pure PostScript.',
... options=dict(version=9, eclevel='M'),
... margin=10, data_mode='8bits')) # Generates PIL.EpsImageFile instance
<PIL.EpsImagePlugin.EpsImageFile instance at ...>
>>> _.show() # Show the image
I get IOError: [Errno 32] Broken pipe
and when I run this to check on the ghostscript and PIL install:
# coding: utf-8
from StringIO import StringIO
from PIL.EpsImagePlugin import EpsImageFile
src = """%!PS-Adobe 2.0
%%BoundingBox: 0 0 144 144
36 36 72 72 rectfill
/Courier findfont 12 scalefont setfont
36 120 moveto (text) show
showpage
"""
im = EpsImageFile(StringIO(src))
im.save('foo.png')
I get IOError: gs failed (status 1)
I tried installing Ghostscript for win64 but I get the same errors.
Any suggestions on where to begin troubleshooting? I can run the ghostscript executables and a command window pops up and I added the correct path to the env path variable.
Thanks.
You need to capture the Ghostscript output to see what the error message is. This is normally written to stderr, I have no idea where this might be going in the Python library but you really need to see this to figure out why Ghostscript is exiting.
You also need to see it to find out if Ghostscript is even being executed. It sounds to me like it isn’t but I don’t know anything about the “python ghostscript 0.41 egg”.