gpt4 book ai didi

python - exe 文件无法正常工作(没有任何反应)

转载 作者:太空宇宙 更新时间:2023-11-03 18:37:46 24 4
gpt4 key购买 nike

当我将文件(snake.py)编译为 exe 时,输出文件(exe 文件)不起作用。我认为这可能是由于编译过程中发生的错误造成的:

missing modules:
? _frozen_importlib imported from importlib

enter image description here

有什么想法吗?

import sys
from cx_Freeze import setup, Executable

base = None
if sys.platform == "win32":
base = "Win32GUI"

setup(
name = "simple_PyQt4",
version = "0.1",
description = "Sample cx_Freeze PyQt4 script",
options = {"build_exe" : {"includes" : "atexit" }},
executables = [Executable("hello_qt.py", base = base)])

最佳答案

我使用PySide,但它应该几乎等同于你的PyQt。

我有这个代码hello_pyside.py:

import sys
from PySide.QtCore import *
from PySide.QtGui import *

class Window(QWidget):
def __init__(self, *args, **kwargs):
QWidget.__init__(self, *args, **kwargs)

self.button = QPushButton("Test", self)
self.button.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

self.layout = QHBoxLayout()
self.layout.setContentsMargins(5, 5, 5, 5)
self.layout.addWidget(self.button)

self.setLayout(self.layout)
self.show()

app = QApplication(sys.argv)
win = Window()
sys.exit(app.exec_())

我将此脚本称为随 cx_freeze 安装的脚本:

c:\Python33\Scripts\cxfreeze.bat hello_pyside.py --target-dir=Bin/pyside --base-name=Win32GUI --target-name=hello_pyside.exe --include-modules=re --exclude-modules=Tkinter

我得到的目录包含:

_bz2.pyd
hello_pyside.exe
PySide.QtCore.pyd
PySide.QtGui.pyd
pyside-python3.3.dll
python33.dll
QtCore4.dll
QtGui4.dll
shiboken-python3.3.dll
unicodedata.pyd

这应该可以正常工作。

关于python - exe 文件无法正常工作(没有任何反应),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21219875/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com