pyinstaller -F -w +转化目标.py文件,生成exe,结果报错,由于我使用PyQt5设计,所以报下面错误,再网上看了很多资料,发现大多数只要使用PyQt5设计的,在转exe时,都会报这个错误,说Qt5的dll路径不对
然后在网上看到了一篇文章,把这个问题给描述了
https://github.com/pyinstaller/pyinstaller/issues/4293
解决方法如下:
import sys, os
if hasattr(sys, 'frozen'):
os.environ['PATH'] = sys._MEIPASS + ";" + os.environ['PATH']
from PyQt5 import QtCore, QtWidgets, QtGui
from PyQt5.QtWidgets import *
from untitled import Ui_MainWindow
from PyQt5.QtGui import *
然后在转成exe就完美解决了