Using cx_freeze in PyQt5, can't find PyQt5

时光总嘲笑我的痴心妄想 提交于 2019-12-10 11:53:03

问题


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).

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]
)

run with:

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

This is my library that I used:

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).

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

Thanks.

Python3.3, PyQt5, Mysqlconnector.


回答1:


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 !




回答2:


Try pyinstaller. It's much better than cxfreeze.



来源:https://stackoverflow.com/questions/19207746/using-cx-freeze-in-pyqt5-cant-find-pyqt5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!