Python exe文件没有';t工作不正常(什么也没发生)

Python exe文件没有';t工作不正常(什么也没发生),python,python-3.x,cx-freeze,Python,Python 3.x,Cx Freeze,当我将文件(snake.py)编译为exe时,输出文件(exe文件)不工作。 我认为这可能是编译过程中出现的错误造成的: missing modules: ? _frozen_importlib imported from importlib 有什么想法吗 import sys from cx_Freeze import setup, Executable base = None if sys.platform == "win32": base = "Win32GUI" se

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

missing modules:
? _frozen_importlib imported from importlib

有什么想法吗

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

我有这个代码
你好_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\u 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

这应该可以正常工作。

您使用什么工具“编译”exe?exe会出现什么错误?它到底是如何“不工作的”?您构建exe的设置是什么?你能成功构建“hello_world.py”吗?你能成功构建像“hello_qt.py”这样的东西吗?我使用cx_freeze。这是我的设置,没有输入我编译的内容(即使是一个简单的hello_qr.py),exe输出不起作用。不会出现任何错误,我的意思是当我试图打开exe文件时什么也不会发生:从cx_freeze导入安装程序导入sys,如果sys.platform==“win32”,则可执行文件base=None: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)])您使用Python 2.x还是Python 3.x?