捆绑包(仅--onefile) [英] Bundle (Just --onefile)

查看:185
本文介绍了捆绑包(仅--onefile)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请阅读所有这篇文章并为我提供帮助.

please read all this post and help me.

我想用pyinstaller创建--onefile可执行文件.

i want to create --onefile executable with pyinstaller.

我在开发方面有这些:

  • Windows 8.1 x64
  • Qt 5.2.1
  • Python 27
  • PyQt5.2.1(使用Visual Studio 2012构建)
  • Visual Studio 2012
  • PyInstaller 2.1
  • pyWin32

和这些在部署端(VirtualBox)(作为干净的VM):

and these in Deployment side (VirtualBox) (as a clean VM):

  • Windows 8 x64
  • vcredist_x64 2012

这是我要构建的简单Python程序:

and this is my simple python program that i want to build:

#main.py
import sys
from PyQt5.QtWidgets import QApplication, QPushButton

app = QApplication(sys.argv)

win = QPushButton("Hello World!")
win.show()

sys.exit(app.exec_())
#------------------------------------------------

好的,当我将其构建为--onedir(pyinstaller main.py)时,它在开发方面和部署方面都可以正常工作.

ok, when i build it as --onedir (pyinstaller main.py) it works fine on development side and deployment side.

当我将其构建为--onefile(pyinstaller -F main.py)时,它在开发方面可以正常工作,但在部署方面却无法工作.

when i build it as --onefile (pyinstaller -F main.py) it works fine on development side but it does not work on deployment side.

并给出此错误:

此应用程序无法启动,因为无法找到或加载该应用程序 Qt平台插件"Windows".

This application failed to start because it could not find or load the Qt platform plugin "windows".

可用的平台插件有:最小,屏幕外,Windows.

Available platform plugins are: minimal, offscreen, windows.

重新安装该应用程序可能会解决此问题.

Reinstalling the application may fix this problem.

我的错是什么?这栋楼是什么问题?

what is my fault?or what is the problem of this building?

就此错误而言,它找不到temp文件夹中_MEIxxxxx文件夹中的qt5_plugins文件夹.

in terms of this error it can not find qt5_plugins folder that is in _MEIxxxxx folder in temp folder.

或者,您是否认为问题出在sys模块?如果是,我该怎么办?

or,do you think problem is from sys module?if yes, what should i do?

感谢提前答复

更新:

我应该说我在构建时有这样的警告和错误:

i should say that i have this warnnings and erro in build-time:

1024警告:没有这样的文件C:\ Python27 \ msvcp90.dll 1024警告: 组装不完整1026错误:组装 amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none not found

1024 WARNING: No such file C:\Python27\msvcp90.dll 1024 WARNING: Assembly incomplete 1026 ERROR: Assembly amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none not found

更新2:

我手动将msvcp90.dllmsvcm90.dll添加到c:\Python27,此警告和错误已解决.

i added msvcp90.dll, msvcm90.dll to c:\Python27 manually, and this warnings and error is solved.

更新3:

qt.conf:

[Paths]
Plugins = qt5_plugins

main.spec:

# -*- mode: python -*-
a = Analysis(['main.py'],
             pathex=['D:\\hello2'],
             hiddenimports=['sip', "PyQt5.QtCore", "PyQt5.QtGui", "PyQt5.QtWidgets"],
             hookspath=None,
             runtime_hooks=None)
pyz = PYZ(a.pure)
plugins = [("qt5_plugins/platforms/qwindows.dll",
             "C:\\Qt\\Qt5.2.1\\5.2.1\\msvc2012_64\\plugins\\platforms\\qwindows.dll", "BINARY")]
data = [
  ("qt.conf", "qt.conf", "DATA")
]
exe = EXE(
    pyz,
    a.scripts,
    a.binaries + plugins,
    a.zipfiles,
    a.datas + data,
    name='main.exe',
    debug=False,
    strip=None,
    upx=True,
    console=True
)

使用pyinstaller自动创建的

qt5_plugins具有平台插件.我认为它不需要作为Extralib手动添加.

qt5_plugins that created automatically with pyinstaller have platform plugin.and i don't think it needs to add manually as extralib.

推荐答案

我刚刚第一次尝试使用pyinstaller并收到缺少的"windows"消息.

I have just tried using pyinstaller for the first time and received the missing 'windows' message.

查看了许多解决方案"并尝试了各种方法之后,我终于解决了,将C:\ Python34 \ Lib \ site-packages \ PyQt4 \ plugins \ platforms中的qwindows.dll放入应用程序目录(dist)中, qt4_plugins \ platforms (我手动创建了platforms目录,pyinstaller创建了qt4_plugins目录)

After looking at many 'solutions' and trying all kinds of things I finally solved by putting the qwindows.dll from C:\Python34\Lib\site-packages\PyQt4\plugins\platforms to the application directory (dist) plus qt4_plugins\platforms (I manually created the platforms directory, pyinstaller created the qt4_plugins directory)

虽然不像创建qt.conf文件那样优雅,但是它可以使应用程序正常工作.

Not as elegant as creating a qt.conf file, but it got the application working.

我应该添加我正在使用Windows 7,python 3.4和PyQt4.

I should add I am using Windows 7, python 3.4 and PyQt4.

这篇关于捆绑包(仅--onefile)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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