Pyinstaller无法在图片上显示python应用?我做错了什么?

问题描述 投票:0回答:1

我有这个imsple代码用于测试。

#!/usr/bin/env python3
import cv2
import sys
import os


if getattr(sys, 'frozen', False):
    app_path = sys.MEIPASS
else:
    app_path = os.path.dirname(os.path.abspath(__file__))



img = cv2.imread('sammy_noise.jpg')
cv2.imshow('It works?', img)
cv2.waitKey(0)
cv2.destroyAllWindows()

只是一个图片展示

我想让这个脚本通过双击来工作,我安装了pypinstaller。我在终端运行这个。

pyinstaller --onefile --add-data="sammy_noise.jpg:." test.py

构建成功,但是当我尝试双击dist文件夹中的exe文件时,什么都没有发生。我到底做错了什么?

python linux exe pyinstaller
1个回答
0
投票

我觉得你应该试试这种方式。

pyinstaller --onefile --add-data=sammy_noise.jpg;. test.py

© www.soinside.com 2019 - 2024. All rights reserved.