我已经使用pyBarcode库在我的软件中生成条形码,其工作完美正常,但是我从命令行加载它,但是一旦我使用py2exe冻结整个软件,我是生成条形码时出现IO错误。IO错误:使用py2exe在冻结后生成条形码时无法打开图像
File "panels.pyc", line 383, in generate
File "barcodeGenerator.pyc", line 9, in generate
File "barcode\base.pyc", line 68, in save
File "barcode\codex.pyc", line 251, in render
File "barcode\base.pyc", line 103, in render
File "barcode\writer.pyc", line 188, in render
File "barcode\writer.pyc", line 280, in _paint_text
File "PIL\ImageFont.pyc", line 248, in truetype
File "PIL\ImageFont.pyc", line 146, in __init__
IOError: cannot open resource
这里的panels.py是我从哪里调用生成barcodeGenerator.py方法的代码如下的python脚本。
barcodeGenerator.py: -
import barcode
from barcode import generate
from barcode.writer import ImageWriter
from PIL import PngImagePlugin
def generate(details,path):
EAN = barcode.get_barcode_class('code128')
ean = EAN(details, writer=ImageWriter())
barcodePic = ean.save(path + 'barcode')
而且是使用setup.py文件是冻结是: -
from distutils.core import setup
import py2exe
includes = ["HuffmanDictionary"]
setup(
options = {
"py2exe": {"includes": includes}
},
console=['MainFrame.py',"extraModules.py","encode.py","decode.py","panels.py","barcodeGenerator.py" ]
)
请替某一个点上的错误,我made.I很接近完成整个软件这是最后一个bug,我正在使用Windows 7 64位。
编辑:已经去过这link并尝试但仍然不适合我。
你能提供一些有关你的py2exe解决方案的更多信息吗?我有同样的问题,并且我已将整个条形码模块包含在配置文件中,但我仍然收到此错误。你的py2exe配置是什么样的? – Andy