有人知道如何解决这个问题吗?我正在尝试创建一个带有模块python条形码的应用程序 当我编译它时,它运行良好,但当我试图将它转换为exe(使用autopytoexe)时,这给了我错误
Traceback (most recent call last):
File "sad.py", line 14, in <module>
File "site-packages\barcode\base.py", line 68, in save
File "site-packages\barcode\ean.py", line 122, in render
File "site-packages\barcode\base.py", line 111, in render
File "site-packages\barcode\writer.py", line 226, in render
File "site-packages\barcode\writer.py", line 356, in _paint_text
File "site-packages\PIL\ImageFont.py", line 648, in truetype
File "site-packages\PIL\ImageFont.py", line 645, in freetype
File "site-packages\PIL\ImageFont.py", line 193, in __init__
OSError: cannot open resource
这是我当前正在运行的代码
import barcode
import os.path
import os
from barcode.writer import ImageWriter
from PIL import Image, ImageDraw, ImageFont
number = "0000000000000"
prodname = "Chicken Biryani"
directory = './Barcodes/'
a = barcode.get_barcode_class('ean13')
img_bar = a(number, writer = ImageWriter())
if not os.path.isdir(directory):
os.mkdir(directory)
img_bar.save("Barcodes\\"+prodname)
img = Image.open("Barcodes\\"+prodname+'.png')
fnt = ImageFont.truetype("arial.ttf",50)
d = ImageDraw.Draw(img)
d.text((80,190), prodname, font=fnt, fill=(0,0,0))
img.save("Barcodes\\"+prodname+'.png')
此库正在使用
DejaVuSansMono
字体。您必须将该字体粘贴到包含.exe
文件的文件夹中相关问题 更多 >
编程相关推荐