GameMaker2k / PyUPC-EAN

PyUPC-EAN is a barcode library/module for Python.
http://pyupcean.sourceforge.net/
Other
29 stars 9 forks source link

AttributeError: 'barcode' object has no attribute 'validate_draw_barcode' when application is frozen. #3

Closed scarygliders closed 8 years ago

scarygliders commented 8 years ago

I am writing a GUI application for Windows which imports upcean from PyUPC-EAN to validate manually-input barcode numbers and generate a barcode image if the code is valid.

When run from the python interpreter, this works perfectly.

Here is a snippet of code where the verification/image generation is happening...

if entered_count == 13:
    bcode = upcean.oopfuncs.barcode(type="ean13", code=str(number)
if entered_count == 14:
    bcode = upcean.oopfuncs.barcode(type="itf14", code=str(number))
    bcode.filename = "./" + number + ".png"
validbcode = bcode.validate_draw_barcode()
if validbcode:

Which runs perfectly fine under the python interpreter.

However, after freezing the application using, say, cx_freeze, the same segment of code generates an AttributeError...

AttributeError: 'barcode' object has no attribute 'validate_draw_barcode'

So it looks like something in the PyUPC-EAN package doesn't get included during the cxfreeze operation.

I have just tried using pyinstaller and get the same result.

I have tried specifically --include-module upcean ehwn using the cx_freeze script, to no avail, and as I stated above, I get the same non-working result when the program is frozen using pyinstaller.

Also, your upc-example.py script works fine when run from the python interpreter, but the same error occurs if it's frozen either with cx_freeze or pyinstaller.

KazukiPrzyborowski commented 8 years ago

It looks like it had to do with imp.find_module('PIL'); PyInstaller dose not seem to work with it. So I added another way to check if PIL/Pillow is installed that works with it.