在PyQt5中使用cx_freeze,找不到PyQt5 [英] Using cx_freeze in PyQt5, can't find PyQt5

查看:191
本文介绍了在PyQt5中使用cx_freeze,找不到PyQt5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的 python3(+ PyQt5)中为 windowz(xp,7,...)构建一个独立的二进制文件

脚本,我不可避免地使用 cx_freeze ,因为其他冻结应用程序无法与python3配合使用(例如 py2exe pyinstaller )。

I want to build a standalone binary file for windowz(xp, 7, ...) from my python3(+ PyQt5) script and I inevitably use cx_freeze because other freezing apps do not work with python3 (like py2exe, pyinstaller).

我阅读了 cx_freeze 文档,很多stackoverflow要求ans对 setup.py‍ 文件使用此配置:

I read the cx_freeze docs and lots of stackoverflow asks ans use this config for setup.py‍‍‍ file :

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

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

and this is my files in workspace:

但是发生了此错误(或另一种错误)。

But this error happened (or another kind of errors).

为什么发生了什么事, setup.py 的配置对pyqt5应用程序来说是很好的?

Why this happened and what config for setup.py is good for pyqt5 app ??

Python3.3,PyQt5,Mysqlconnector。

Python3.3, PyQt5, Mysqlconnector.

推荐答案

我通过找到另一个解决了这个问题dist目录附近的目录名为 build ,所有库文件都在其中,我删除了 targetDir = r dist 部分 setup.py 的所有内容都可以!

I solved this problem with find another directory near the dist directory called build and all library files are in there, i delete targetDir = r"dist" part of setup.py and everythings is alright !

这篇关于在PyQt5中使用cx_freeze,找不到PyQt5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆