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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

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

發布時間:2024/9/30 python 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【问题记录】python的py文件生成exe可执行程序闪退 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

今天想弄一下這個,記錄一下過程:
1.
pip install pyinstaller -i https://pypi.tuna.tsinghua.edu.cn/simple
pyinstaller vei.py
執行這個之后生成了build目錄和exe文件,但發現exe存在閃退問題:

查了一下說缺少相關包,繼續下載:
pip install pypiwin32 -i https://pypi.tuna.tsinghua.edu.cn/simple

https://www.lfd.uci.edu/~gohlke/pythonlibs/#pycairo下載相關包復制到當前項目下:
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
一些七七八八的包,也不知道干什么用的,查到有文章說要下載這些包。

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

用參數-F 這樣dist下面只有exe文件

報錯信息顯示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
不知道執行這個exe還是顯示模塊找不到,于是重新寫了一個py文件再次打包:
已經可以執行了。說明運行exe成功。

另外運行一段修改png為jpg的拒絕訪問問題:

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轉換JPG 錯誤", 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)

一開始一直報錯顯示permission denied
方法:用管理員身份運行pycharm就好了
再次打開文件,后綴已經修改。

與50位技術專家面對面20年技術見證,附贈技術全景圖

總結

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

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。