【发布时间】:2013-10-06 10:21:09
【问题描述】:
我想从我的python3(+ PyQt5) 脚本为windowz(xp, 7, ...) 构建一个独立的二进制文件,我不可避免地使用cx_freeze,因为其他冻结应用程序不适用于python3(如py2exe、pyinstaller)。
我阅读了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