問(wèn)題描述
我是編碼新手,我需要將我的 py 文件轉(zhuǎn)換為 exe.我嘗試了 py2exe,但它不適用于 python 3.5.然后我嘗試了pyinstaller并且它工作了,但是當(dāng)我將PyQt5添加到程序中時(shí),pyinstaller也失敗了.我嘗試了nuitka,它構(gòu)建了exe,但是當(dāng)我單擊exe文件時(shí),它會(huì)顯示一個(gè)控制臺(tái)幾秒鐘并關(guān)閉.我需要一個(gè)在激活后顯示 gui 的 exe.以下是我在程序中使用的模塊:
I'm new to coding and I need to transform my py file to an exe. I tried py2exe and it didn't work with python 3.5. Then I tried pyinstaller and it worked, but when I added PyQt5 to the program, pyinstaller also failed. I tried nuitka, and it builds the exe, but when I click on the exe file it shows a console for a few seconds and closes. I need an exe which shows a gui after being activated. Here are the modules that I used in the program:
import P4
import time
from datetime import datetime,date
import traceback
import os
import sys
import threading
from PyQt5 import QtCore
from PyQt5 import QtGui
from PyQt5.QtWidgets import *
from PyQt5.QtCore import QCoreApplication, QTimer
我從 nuitka exe 文件中得到的錯(cuò)誤:
Error I get from nuitka exe file:
我從 pyinstaller exe 文件中得到的錯(cuò)誤:
Error I get from pyinstaller exe file:
pyinstaller 需要的 Dll:dll
Dll's that pyinstaller needs: dlls
推薦答案
我已經(jīng)弄清楚如何使用 Python 3.5 和 pyinstaller 制作一個(gè) exe.你需要安裝這個(gè):
I've figured out how to make an exe with Python 3.5 and pyinstaller. You need to install this:
pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip --upgrade
然后添加 PyQt5 dll 的路徑.我用這個(gè):
Then add path to PyQt5 dll's. I used this:
pyinstaller -y --clean --paths C:TEMPenvLibsite-packagesPyQt5Qtin
這篇關(guān)于Python 3.5 + PyQt5 到獨(dú)立 exe的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!