【问题标题】:Using cx_freeze in PyQt5, can't find PyQt5在 PyQt5 中使用 cx_freeze,找不到 PyQt5
【发布时间】:2013-10-06 10:21:09
【问题描述】:

我想从我的python3(+ PyQt5) 脚本为windowz(xp, 7, ...) 构建一个独立的二进制文件,我不可避免地使用cx_freeze,因为其他冻结应用程序不适用于python3(如py2exepyinstaller)。

我阅读了cx_freeze 文档,并且很多 stackoverflow 询问并将此配置用于setup.py‍‍‍ 文件:

import sys
from cx_Freeze import setup, Executable

path_platforms = ( "C:\Python33\Lib\site-packages\PyQt5\plugins\platforms\qwindows.dll", "platforms\qwindows.dll" )

includes = ["atexit","PyQt5.QtCore","PyQt5.QtGui", "PyQt5.QtWidgets"]
includefiles = [path_platforms]
excludes = [
    '_gtkagg', '_tkagg', 'bsddb', 'curses', 'email', 'pywin.debugger',
    'pywin.debugger.dbgcon', 'pywin.dialogs', 'tcl',
    'Tkconstants', 'Tkinter'
]
packages = ["os"]
path = []

# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {
                     "includes":      includes, 
                     "include_files": includefiles,
                     "excludes":      excludes, 
                     "packages":      packages, 
                     "path":          path
}

# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
exe = None
if sys.platform == "win32":
    exe = Executable(
      script="D:\\imi\\aptanaWorKPCworkspace\\azhtel\\tel.py",
      initScript = None,
      base="Win32GUI",
      targetDir = r"dist",
      targetName="tel.exe",
      compress = True,
      copyDependentFiles = True,
      appendScriptToExe = False,
      appendScriptToLibrary = False,
      icon = None
    )

setup(  
      name = "telll",
      version = "0.1",
      author = 'me',
      description = "My GUI application!",
      options = {"build_exe": build_exe_options},
      executables = [exe]
)

运行:

python D:\imi\aptanaWorKPCworkspace\azhtel\setup.py build

这是我使用的图书馆:

from PyQt5 import QtGui, QtCore, QtWidgets
import sys
from telGui import Ui_MainWindow
import mysql
import mysql.connector
from mysql.connector import errorcode

这是我在工作区中的文件:

但是发生了这个错误(或其他类型的错误)。

为什么会发生这种情况,setup.py 的什么配置对 pyqt5 应用有好处??

谢谢。

Python3.3、PyQt5、Mysql 连接器。

【问题讨论】:

    标签: python-3.x cx-freeze pyqt5


    【解决方案1】:

    我通过在 dist 目录附近找到另一个名为 build 的目录解决了这个问题,并且所有库文件都在那里,我删除了 setup.py 的一部分 targetDir = r"dist" 并且一切都很好!

    【讨论】:

    • 是的 - 仅在 Executable 上设置 targetDir 会将其与所需的其余文件放在不同的目录中。这很令人困惑,所以我为此提交了an issue
    【解决方案2】:

    试试 pyinstaller。比 cxfreeze 好多了。

    【讨论】:

      猜你喜欢
      • 2013-12-13
      • 1970-01-01
      • 1970-01-01
      • 2017-09-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-09
      相关资源
      最近更新 更多