pyinstaller打包的exe运行不了
这是打包界面https://dd-static.jd.com/ddimg/jfs/t1/61080/6/20692/309196/62fe5f1cEb32bc945/d8745fa4eb66c0f5.png
这是运行闪退前1秒
https://dd-static.jd.com/ddimg/jfs/t1/171068/11/29494/145080/62fe5f85Ea436202e/7bb7fedf1a989b45.jpg
在VSCode和cmd里运行.py文件都正常,就是pyinstaller -F打包成一个exe之后就运行不了,求解{:1_923:} 用pyinstaller -F -w 试试 wty3025 发表于 2022-8-19 00:09
用pyinstaller -F -w 试试
写的就是控制台程序。。-W了还怎么运行啊。 楼主方便把代码发出来让我试一试吗 icodeme 发表于 2022-8-19 00:52
楼主方便把代码发出来让我试一试吗
import os
import cv2
import subprocess
def read():# 读取图片
for file in os.listdir(os.getcwd()):
if file.endswith("png") or file.endswith("jpg") or file.endswith("jpeg") or file.endswith(
"png") or file.endswith("tif") or file.endswith("tiff"):
break
return file
def rsz(img, w, h):# 修改尺寸
n = cv2.resize(img, (w, h), interpolation=cv2.INTER_AREA)
return n
def cmd(shell):# 不显示控制台窗口
subprocess.call(shell,
creationflags=0x00000008)
return
def qg(ns, names):# 切割
i = 0
while i < len(names):
cv2.imwrite(names, ns, [cv2.IMWRITE_TIFF_RESUNIT, 3,
cv2.IMWRITE_TIFF_XDPI, 100, cv2.IMWRITE_TIFF_YDPI, 100])
i = i + 1
return
def re(names):# 删除
i = 0
while i < len(names):
os.remove(names)
i = i + 1
return
if __name__ == "__main__":# 入口
file = read()
lname = os.path.splitext(file)[-1]
os.rename(file, "img" + lname)
img = cv2.imread("img" + lname)
os.rename("img" + lname, file)
def xz():# 选择
k = input("\n " + read() + """\n
1.三联画160x60(40x60 80x60 40x60)
2.三联画200x70(50x70 100x70 50x70)
3.三联画240x80(60x80 120x80 60x80)
4.三联画280x90(70x90 140x90 70x90)
5.四联画140x90(30x60 40x80 40x80 30x60)
6.四联画180x110(40x80 50x100 50x100 40x80)
7.四联画220x130(50x100 60x120 60x120 50x100)
8.五联画1100x75(30x45 30x60 30x75 30x60 30x45)
9.五联画200x100(40x60 40x80 40x100 40x80 40x60)
10.五联画250x120(50x80 50x100 50x120 50x100 50x80)
请选择:""")
return k
match xz():
case '1':# 三联画160x60(40x60 80x60 40x60)
n = rsz(img, 16000, 6000)
qg((n, n, n[0:6000,
12000:16000]), ('A40x60.tif', 'B80x60.tif', 'C40x60.tif'))
cmd('magick A40x60.tif B80x60.tif C40x60.tif -bordercolor black -resize 10% ABCDE.png')
cmd(
'magick -background None -gravity center xc:none ABCDE-0.png xc:none ABCDE-1.png xc:none ABCDE-2.png xc:none +append A.png')
re(('ABCDE-0.png', 'ABCDE-1.png',
'ABCDE-2.png'))
case '2':# 三联画200x70(100x70 100x70 100x70)
n = rsz(img, 20000, 7000)
qg((n, n, n),
('A100x70.tif', 'B100x70.tif', 'C100x70.tif'))
cmd('magick A100x70.tif B100x70.tif C100x70.tif -bordercolor black -resize 10% ABCDE.png')
cmd(
'magick -background None -gravity center xc:none ABCDE-0.png xc:none ABCDE-1.png xc:none ABCDE-2.png xc:none +append A.png')
re(('ABCDE-0.png', 'ABCDE-1.png',
'ABCDE-2.png'))
case '3':# 三联画240x80(60x80 120x80 60x80)
n = rsz(img, 24000, 8000)
qg((n, n, n),
('A60x80.tif', 'B120x80.tif', 'C60x80.tif'))
cmd('magick A60x80.tif B120x80.tif C60x80.tif -bordercolor black -resize 10% ABCDE.png')
cmd(
'magick -background None -gravity center xc:none ABCDE-0.png xc:none ABCDE-1.png xc:none ABCDE-2.png xc:none +append A.png')
re(('ABCDE-0.png', 'ABCDE-1.png',
'ABCDE-2.png'))
case '4':# 三联画280x90(70x90 140x90 70x90)
n = rsz(img, 28000, 9000)
qg((n, n, n),
('A70x90.tif', 'B140x90.tif', 'C70x90.tif'))
cmd('magick A70x90.tif B140x90.tif C70x90.tif -bordercolor black -resize 10% ABCDE.png')
cmd(
'magick -background None -gravity center xc:none ABCDE-0.png xc:none ABCDE-1.png xc:none ABCDE-2.png xc:none +append A.png')
re(('ABCDE-0.png', 'ABCDE-1.png',
'ABCDE-2.png'))
case '5':# 四联画140x90(30x60 40x80 40x80 30x60)
n = rsz(img, 14000, 9000)
qg((n, n, n,
n), ('A30x60.tif', 'B40x80.tif', 'C40x80.tif', 'D30x60.tif'))
case '6':# 四联画180x110(40x80 50x100 50x100 40x80)
n = rsz(img, 18000, 11000)
qg((n, n, n,
n), ('A40x80.tif', 'B50x100.tif', 'C50x100.tif', 'D40x80.tif'))
case '7':# 四联画220x130(50x100 60x120 60x120 50x100)
n = rsz(img, 22000, 13000)
qg((n, n, n,
n), ('A50x100.tif', 'B60x120.tif', 'C60x120.tif', 'D50x100.tif'))
case '8':# 五联画1100x75(30x45 30x60 30x75 30x60 30x45)
n = rsz(img, 15000, 7500)
qg((n, n, n, n,
n), ('A30x45.tif', 'B30x60.tif', 'C30x75.tif', 'D30x60.tif', 'E30x45.tif'))
cmd('magick A30x45.tif B30x60.tif C30x75.tif D30x60.tif E30x45.tif -bordercolor black -resize 10% ABCDE.png')
cmd('magick -background None -gravity center xc:none ABCDE-0.png xc:none ABCDE-1.png xc:none ABCDE-2.png xc:none ABCDE-3.png xc:none ABCDE-4.png xc:none +append A.png')
re(('ABCDE-0.png', 'ABCDE-1.png',
'ABCDE-2.png', 'ABCDE-3.png', 'ABCDE-4.png'))
case '9':# 五联画200x100(40x60 40x80 100x100 40x80 40x60)
n = rsz(img, 20000, 10000)
qg((n, n, n, n,
n), ('A40x60.tif', 'B40x80.tif', 'C40x100.tif', 'D40x80.tif', 'E40x60.tif'))
cmd('magick A40x60.tif B40x80.tif C40x100.tif D40x80.tif E40x60.tif -bordercolor black -resize 10% ABCDE.png')
cmd('magick -background None -gravity center xc:none ABCDE-0.png xc:none ABCDE-1.png xc:none ABCDE-2.png xc:none ABCDE-3.png xc:none ABCDE-4.png xc:none +append A.png')
re(('ABCDE-0.png', 'ABCDE-1.png',
'ABCDE-2.png', 'ABCDE-3.png', 'ABCDE-4.png'))
case '10':# 五联画250x120(50x80 50x100 50x120 50x100 50x80)
n = rsz(img, 25000, 12000)
qg((n, n, n, n,
n), ('A50x80.tif', 'B50x100.tif', 'C50x120.tif', 'D50x100.tif', 'E50x80.tif'))
cmd('magick A50x80.tif B50x100.tif C50x120.tif D50x100.tif E50x80.tif -bordercolor black -resize 10% ABCDE.png')
cmd('magick -background None -gravity center xc:none ABCDE-0.png xc:none ABCDE-1.png xc:none ABCDE-2.png xc:none ABCDE-3.png xc:none ABCDE-4.png xc:none +append A.png')
re(('ABCDE-0.png', 'ABCDE-1.png',
'ABCDE-2.png', 'ABCDE-3.png', 'ABCDE-4.png'))
icodeme 发表于 2022-8-19 00:52
楼主方便把代码发出来让我试一试吗
在线等!急! 打包的依赖问题 cv2 opencv 手动改一下打包过程中有一个生成文件 添加进去重新打包 JUNGLE_CN 发表于 2022-8-19 01:04
打包的依赖问题 cv2 opencv 手动改一下打包过程中有一个生成文件 添加进去重新打包
pyinstaller -–clean -F -i icon.ico a.py C:\Users\Administrator\AppData\Local\Programs\Python\Python310\Lib\site-packages\cv2
这样把opencv的目录加进去打包还是不行 解决了,呜呜呜,原来是opencv版本太高的原因,降了个版本就正常了,呜呜呜,搞了一天,电脑系统都重装了, opencv版本太高!!
页:
[1]
2