【发布时间】:2020-04-07 23:05:08
【问题描述】:
我使用 Windows 10、python 3.7 和 pyinstaller 3.5 版。
我在 pycharm 中编写了一些脚本,当我点击运行(来自 pycharm IDE)时,它工作正常。
但是当我通过pyinstaller执行到exe(“pyinstaller --onefile design.py”)时,
我单击 dist 文件夹 (design.exe) 中的文件并收到此错误
Traceback (most recent call last):
File "design21.py", line 10, in <module>
ModuleNotFoundError: No module named 'PyQt5'
[11116] Failed to execute script design21
我的代码以:
开头 # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'gui_with_layouts.ui'
#
# Created by: PyQt5 UI code generator 5.13.0
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import QThread,pyqtSignal
from style import *
from firebase import firebase
import xlrd
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains
import time
from PyQt5.QtWidgets import *
stop_flag = False
更新:
我不知道怎么做,但我做了下一步并且不知何故它起作用了:
- 删除第 10 行和第 11 行(导入“Pyqt5”)
- 执行新的exe(来自cmd推荐
pyinstaller --onefile design21.py) - 从 dist 文件夹运行新的 exe 文件(当然我得到了错误,因为我使用了 moudle 'Pyqt5' 而没有导入它)。 4.再次添加导入行(我删除的行 10 和 11)。
- 再次执行新的exe(来自cmd的推荐
pyinstaller --onefile design21.py) 然后当我运行新的exe时它工作...... 不知道为什么,但它起作用了。
【问题讨论】:
-
请包含所有相关代码,尤其是文件
design21.py的前十行。
标签: python pyqt5 exe pyinstaller