您的位置:首页 > 编程语言 > Python开发

python3.4 +pyqt5 +cx_freeze 打包成exe

2015-12-02 15:41 579 查看
1、安装cx_freeze
  通过cx_Freeze-4.3.4-cp34-none-win_amd64.whl安装

安装方式:
cmd切换目录:运行 pip3 install cx_Freeze-4.3.4-cp34-none-win_amd64.whl

下载链接:http://www.lfd.uci.edu/~gohlke/pythonlibs/#cx_freeze

2、编写setup.py文件

#!/usr/bin/env python

import sys

from cx_Freeze import setup, Executable

base None
if sys.platform == 'win32':
    base 'Win32GUI'
packages = [
   
'os'
]
options {
   
'build_exe'{'packages'packages, 'include_files': ['setup.properties']'icon''bus32.ico',

                  "includes""atexit"},
}
executables = [Executable('install.py', base=base, targetName='installpay.exe')]
setup(
    name="PayInstall",

    version="1.0.0",

    url='http://pay.dreams.edu.cn/',

    author='liuguanghui',

    author_email='sunsray@163.com',

    description="Install for Pay PlatForm",

    options=options,

    executables=executables, requires=['PyQt5']
)

3、cmd运行:python3 setup build或者python setup.py bdist_msi打包
4、在其他机器上运行报错:竟然冒出个X:



费尽力气最后找出原因(stackoverflow):
http://stackoverflow.com/questions/24135953/executable-created-using-cx-freeze-in-windows-7-crashes-with-errors-about-pyqt5

 上面提出了首先查看这两个dll:QWindows.DLL and libEGL.dll h是否在生成的文件目录里存在

 然后:
includes': ['atexit']这个必须有


mport sys

from cx_Freeze import setup, Executable

base = None

if sys.platform == 'win32':

    base = 'Win32GUI'

setup(name = 'spamandeggs',

      version = '0.0.1',

      executables = [Executable('spamandeggs.pyw', base=base)],

      options = {'build_exe': {'includes': ['atexit']}})


但发现以上都没解决,
从最后的回答解决了!!将msvcp100.dll拷贝到生成目录里即可

0down vote
I got the same error today, and finally found a solution for me after a whole day of searching. I copied msvcp100.dll, and everything works.

wft

shareimprove
this answer
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python pyqt exe