日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > python >内容正文

python

【问题记录】python的py文件生成exe可执行程序闪退

發(fā)布時(shí)間:2024/9/30 python 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【问题记录】python的py文件生成exe可执行程序闪退 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

今天想弄一下這個(gè),記錄一下過(guò)程:
1.
pip install pyinstaller -i https://pypi.tuna.tsinghua.edu.cn/simple
pyinstaller vei.py
執(zhí)行這個(gè)之后生成了build目錄和exe文件,但發(fā)現(xiàn)exe存在閃退問(wèn)題:

查了一下說(shuō)缺少相關(guān)包,繼續(xù)下載:
pip install pypiwin32 -i https://pypi.tuna.tsinghua.edu.cn/simple

https://www.lfd.uci.edu/~gohlke/pythonlibs/#pycairo下載相關(guān)包復(fù)制到當(dāng)前項(xiàng)目下:
pip install pycairo-1.20.0-cp39-cp39-win_amd64.whl


pip install PyQt5
pip install IPython
pip install wxPython
pip install ipykernel
pip install zmq
一些七七八八的包,也不知道干什么用的,查到有文章說(shuō)要下載這些包。

然后在命令行輸入pyinstaller 說(shuō)不是可執(zhí)行程序,于是在命令行全局安裝 pip intall pyinstaller

用參數(shù)-F 這樣dist下面只有exe文件

報(bào)錯(cuò)信息顯示PIL模塊找不到,于是:安裝PIL顯示失敗,于是安裝pillow
C:\Windows\system32>pip install PIL
ERROR: Could not find a version that satisfies the requirement PIL
ERROR: No matching distribution found for PIL

C:\Windows\system32>pip install Pillow
Collecting Pillow
Using cached Pillow-8.1.1-cp39-cp39-win_amd64.whl (2.2 MB)
Installing collected packages: Pillow
Successfully installed Pillow-8.1.1
不知道執(zhí)行這個(gè)exe還是顯示模塊找不到,于是重新寫了一個(gè)py文件再次打包:
已經(jīng)可以執(zhí)行了。說(shuō)明運(yùn)行exe成功。

另外運(yùn)行一段修改png為jpg的拒絕訪問(wèn)問(wèn)題:

import osfrom PIL import Image import cv2 as cv def PNG_JPG(PngPath):img = cv.imread(PngPath, 0)w, h = img.shape[::-1]infile = PngPathoutfile = os.path.splitext(infile)[0] + ".jpg"img = Image.open(infile)img = img.resize((int(w / 2), int(h / 2)), Image.ANTIALIAS)try:if len(img.split()) == 4:# prevent IOError: cannot write mode RGBA as BMPr, g, b, a = img.split()img = Image.merge("RGB", (r, g, b))img.convert('RGB').save(outfile, quality=70)os.remove(PngPath)else:img.convert('RGB').save(outfile, quality=70)os.remove(PngPath)return outfileexcept Exception as e:print("PNG轉(zhuǎn)換JPG 錯(cuò)誤", e)path_root = os.getcwd() Path= 'C:\\Users\\pic\\' img_dir = os.listdir(Path) for img in img_dir:if img.endswith('.png'):PngPath= Path + imgPNG_JPG(PngPath) img_dir = os.listdir(Path) for img in img_dir:print(img)

一開始一直報(bào)錯(cuò)顯示permission denied
方法:用管理員身份運(yùn)行pycharm就好了
再次打開文件,后綴已經(jīng)修改。

與50位技術(shù)專家面對(duì)面20年技術(shù)見證,附贈(zèng)技術(shù)全景圖

總結(jié)

以上是生活随笔為你收集整理的【问题记录】python的py文件生成exe可执行程序闪退的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。