How to make an .exe file from python project with qt framework(pyside2) with cx_freeze properly?

最后都变了- 提交于 2020-01-16 11:16:01

问题


I've searched this for quite a while and I give up. I've created setup.py file with all needed options. Call "python setup.py build" and I got the .exe file which is working, but only on my computer. When I'm trying to launch that file on the other computer - it fails to start. Because in all the chains of modules in the last one ther is something like it:

"F:\*myfilepath from the original system to*\lib\site-packages\shiboken2\__init__.py", line 27 in <module>
ImportError: DLL load failed:%1 is not Win32 application.

In shiboken's init.py on 27th line there is

from .shiboken2 import *

So, I've freezed this project on the second system and after launching this on the first one - the same exact problem. On the system where .exe file was created it launches just fine. I've tried to use Dependacy Walker and put every possible .dll there which's missing, but there are only windows api dlls which actually don't need to be ever called by application and this didn't work. Also when I'm trying make an msi installer even with empty project(just import PySide2) it makes an Exception:

Traceback (most recent call last):
  File "setup.py", line 39, in <module>
    executables = [Executable("Namer_main.py", base=base, targetName='Namer.exe'
, icon='dude.ico')])
  File "F:\Programs\Python\Python37-32\lib\site-packages\cx_Freeze\dist.py", lin
e 348, in setup
    distutils.core.setup(**attrs)
  File "F:\Programs\Python\Python37-32\lib\distutils\core.py", line 148, in setu
p
    dist.run_commands()
  File "F:\Programs\Python\Python37-32\lib\distutils\dist.py", line 966, in run_
commands
    self.run_command(cmd)
  File "F:\Programs\Python\Python37-32\lib\distutils\dist.py", line 985, in run_
command
    cmd_obj.run()
  File "F:\Programs\Python\Python37-32\lib\site-packages\cx_Freeze\windist.py",
line 416, in run
    self.add_files()
  File "F:\Programs\Python\Python37-32\lib\site-packages\cx_Freeze\windist.py",
line 139, in add_files
    cab.commit(db)
  File "F:\Programs\Python\Python37-32\lib\msilib\__init__.py", line 215, in com
mit
    FCICreate(filename, self.files)
ValueError: FCI error 1

my setup.py is like this:

import sys
from cx_Freeze import setup, Executable

build_exe_options = {'include_msvcr': True, "packages": ["os", "sys", "shelve", "random", "re"]}
# GUI applications require a different base on Windows (the default is for a
# console application).

base = None
if sys.platform == "win32":
    base = "Win32GUI"

setup(name = "Namer",
      version = "0.3",
      description = "Namer GUI App",
      options = {"build_exe": build_exe_options},
      executables = [Executable("Namer_main.py", base=base, targetName='Namer.exe', icon='dude.ico')])

All the problems appear even on empty projects with PySide2 imports So mainly it's the problem of shiboken2 and cx_freeze compatibility, I think. But other people made it work. Specs: Windows 7(x64), Python 3.7.5, latest PySide2 and cx_freeze(from PyPi).

来源:https://stackoverflow.com/questions/58892470/how-to-make-an-exe-file-from-python-project-with-qt-frameworkpyside2-with-cx

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