最新消息:20210917 已从crifan.com换到crifan.org

[已解决]pyinstaller打包exe运行出错:fatal error returned -1

Python crifan 4853浏览 0评论

别人遇到的:exe运行出错  单独py可以正常运行

运行exe出错:

对应打包命令是:

python pyinstaller.py -w –onefile -p C:\Python27\Lib\site-packages\PyQt4;C:\Python27\;C:\Python27\Lib;C:\Python27\Lib\site-packages\pywin32_system32 –icon="1.ico" DiagnosticTool.py

警告是:

missing module named PyQt4.QtCore.QCoreApplication – imported by PyQt4.QtCore, Y:\temp\GBDT\Trunk\Src\PyInstaller\loader\rthooks\pyi_rth_qt4plugins.py

missing module named PyQt4.QtCore.PYQT_VERSION_STR – imported by PyQt4.QtCore, PyQt4.uic

missing module named nt._isdir – imported by nt, ntpath

missing module named nt._getfullpathname – imported by nt, ntpath

missing module named nt._exit – imported by nt, os

missing module named strop.whitespace – imported by strop, string

missing module named strop.maketrans – imported by strop, string

missing module named strop.lowercase – imported by strop, string

missing module named strop.uppercase – imported by strop, string

missing module named _sre.MAXREPEAT – imported by _sre, sre_constants

missing module named itertools.islice – imported by itertools, repr, heapq

missing module named itertools.ifilterfalse – imported by itertools, sets

missing module named itertools.ifilter – imported by itertools, sets

missing module named itertools.starmap – imported by itertools, collections

missing module named itertools.repeat – imported by itertools, collections

missing module named itertools.imap – imported by itertools, heapq, collections

missing module named itertools.tee – imported by itertools, heapq

missing module named itertools.izip – imported by itertools, heapq

missing module named itertools.chain – imported by itertools, heapq, collections

missing module named itertools.count – imported by itertools, heapq

missing module named org.PyStringMap – imported by org, copy

missing module named org – imported by copy

missing module named exceptions.ReferenceError – imported by exceptions, weakref

missing module named _weakref.ref – imported by _weakref, _weakrefset, weakref

missing module named _weakref.ReferenceType – imported by _weakref, weakref

missing module named _weakref.proxy – imported by _weakref, weakref

missing module named _weakref.getweakrefs – imported by _weakref, weakref

missing module named _weakref.getweakrefcount – imported by _weakref, weakref

missing module named _weakref.ProxyType – imported by _weakref, weakref

missing module named _weakref.CallableProxyType – imported by _weakref, weakref

missing module named copy.deepcopy – imported by copy, weakref, sets

missing module named array.array – imported by array, httplib

missing module named re._compile – imported by re, sre

missing module named re.__all__ – imported by re, sre

missing module named _warnings.warn_explicit – imported by _warnings, warnings

missing module named _warnings.filters – imported by _warnings, warnings

missing module named _warnings.once_registry – imported by _warnings, warnings

missing module named _warnings.default_action – imported by _warnings, warnings

missing module named _warnings.warn – imported by _warnings, warnings

missing module named warnings.warn – imported by warnings, random

missing module named ‘PyQt4.uic.port_v3’.as_string – imported by ‘PyQt4.uic.port_v3’, PyQt4.uic.icon_cache

missing module named ‘PyQt4.uic.port_v3’ – imported by PyQt4.uic.icon_cache

missing module named ‘PyQt4.elementtree’.SubElement – imported by ‘PyQt4.elementtree’, PyQt4.uic.uiparser

missing module named ‘PyQt4.elementtree’.parse – imported by ‘PyQt4.elementtree’, PyQt4.uic.uiparser

missing module named ‘PyQt4.elementtree’ – imported by PyQt4.uic.uiparser

missing module named elementtree.SubElement – imported by elementtree, PyQt4.uic.uiparser

missing module named elementtree.parse – imported by elementtree, PyQt4.uic.uiparser

missing module named elementtree – imported by PyQt4.uic.uiparser

missing module named ElementC14N._serialize_c14n – imported by ElementC14N, xml.etree.ElementTree

missing module named ElementC14N – imported by xml.etree.ElementTree

missing module named _io.DEFAULT_BUFFER_SIZE – imported by _io, io

missing module named _io.BytesIO – imported by _io, io

missing module named _io.open – imported by _io, io

missing module named _io.BufferedWriter – imported by _io, io

missing module named _io.FileIO – imported by _io, io

missing module named _io.BlockingIOError – imported by _io, io

missing module named _io.IncrementalNewlineDecoder – imported by _io, io

missing module named _io.BufferedReader – imported by _io, io

missing module named _io.BufferedRandom – imported by _io, io

missing module named _io.StringIO – imported by _io, io

missing module named _io.BufferedRWPair – imported by _io, io

missing module named _io.TextIOWrapper – imported by _io, io

missing module named _io.UnsupportedOperation – imported by _io, io

missing module named pwd – imported by posixpath, getpass

missing module named _scproxy._get_proxy_settings – imported by _scproxy, urllib

missing module named _scproxy._get_proxies – imported by _scproxy, urllib

missing module named _scproxy – imported by urllib

missing module named EasyDialogs.AskPassword – imported by EasyDialogs, getpass

missing module named EasyDialogs – imported by getpass

missing module named termios – imported by getpass

missing module named SOCKS – imported by ftplib

missing module named errno.EINVAL – imported by errno, StringIO

missing module named errno.ENOENT – imported by errno, gettext

missing module named cStringIO.StringIO – imported by cStringIO, pprint, gettext, shlex, tempfile, pickle, PyQt4.uic.port_v2.string_io, socket, quopri, httplib, email.parser, email.message, email.generator, email.iterators, urllib, xml.sax, encodings.uu_codec, encodings.quopri_codec

missing module named binascii.b2a_base64 – imported by binascii, email.base64mime

missing module named binascii.a2b_base64 – imported by binascii, email.base64mime

missing module named binascii.a2b_uu – imported by binascii, encodings.uu_codec

missing module named binascii.b2a_uu – imported by binascii, encodings.uu_codec

missing module named binascii.b2a_qp – imported by binascii, quopri

missing module named binascii.a2b_qp – imported by binascii, quopri

missing module named binascii.hexlify – imported by binascii, random

missing module named locale.normalize – imported by locale, gettext

missing module named _struct.__doc__ – imported by _struct, struct

missing module named _struct._clearcache – imported by _struct, struct

missing module named _functools.partial – imported by _functools, functools

missing module named _functools.reduce – imported by _functools, functools

missing module named operator.attrgetter – imported by operator, inspect

missing module named operator.itemgetter – imported by operator, collections, heapq

missing module named operator.eq – imported by operator, collections

missing module named datetime.date – imported by datetime, _strptime

missing module named os.urandom – imported by os, random

missing module named math.sin – imported by math, random

missing module named math.sqrt – imported by math, random

missing module named math.cos – imported by math, random

missing module named math.acos – imported by math, random

missing module named math.ceil – imported by math, random

missing module named math.exp – imported by math, random

missing module named math.log – imported by math, random

missing module named math.e – imported by math, random

missing module named math.pi – imported by math, random

missing module named thread.allocate_lock – imported by thread, _strptime

missing module named thread._local – imported by thread, threading

missing module named thread.stack_size – imported by thread, threading

missing module named thread.get_ident – imported by thread, collections

missing module named _ssl.PROTOCOL_SSLv2 – imported by _ssl, ssl

missing module named _ssl.PROTOCOL_TLSv1 – imported by _ssl, ssl

missing module named _ssl.PROTOCOL_SSLv23 – imported by _ssl, ssl

missing module named _ssl.PROTOCOL_SSLv3 – imported by _ssl, ssl

missing module named _ssl.SSL_ERROR_EOF – imported by _ssl, ssl, socket

missing module named _ssl.SSL_ERROR_WANT_WRITE – imported by _ssl, ssl, socket

missing module named _ssl.SSL_ERROR_ZERO_RETURN – imported by _ssl, ssl, socket

missing module named _ssl.SSL_ERROR_WANT_X509_LOOKUP – imported by _ssl, ssl, socket

missing module named _ssl.SSL_ERROR_SSL – imported by _ssl, ssl, socket

missing module named _ssl.SSL_ERROR_WANT_CONNECT – imported by _ssl, ssl, socket

missing module named _ssl.SSL_ERROR_INVALID_ERROR_CODE – imported by _ssl, ssl, socket

missing module named _ssl.SSL_ERROR_WANT_READ – imported by _ssl, ssl, socket

missing module named _ssl.SSL_ERROR_SYSCALL – imported by _ssl, ssl, socket

missing module named _ssl.RAND_status – imported by _ssl, ssl, socket

missing module named _ssl.RAND_egd – imported by _ssl, ssl, socket

missing module named _ssl.RAND_add – imported by _ssl, ssl, socket

missing module named _ssl.CERT_REQUIRED – imported by _ssl, ssl

missing module named _ssl.CERT_NONE – imported by _ssl, ssl

missing module named _ssl.CERT_OPTIONAL – imported by _ssl, ssl

missing module named _ssl.SSLError – imported by _ssl, ssl, socket

missing module named _ssl.OPENSSL_VERSION_NUMBER – imported by _ssl, ssl

missing module named _ssl.OPENSSL_VERSION_INFO – imported by _ssl, ssl

missing module named _ssl.OPENSSL_VERSION – imported by _ssl, ssl

missing module named sys.py3kwarning – imported by sys, httplib

missing module named fcntl – imported by tempfile, subprocess

missing module named socket.getnameinfo – imported by socket, ssl

missing module named socket.error – imported by socket, ssl

missing module named socket.socket – imported by socket, ssl

missing module named socket._delegate_methods – imported by socket, ssl

missing module named socket._fileobject – imported by socket, ssl

missing module named rourl2path.url2pathname – imported by rourl2path, urllib

missing module named rourl2path.pathname2url – imported by rourl2path, urllib

missing module named rourl2path – imported by urllib

missing module named collections.namedtuple – imported by collections, inspect, unittest.util, difflib, doctest, urlparse

missing module named readline – imported by cmd, pdb

missing module named cPickle.loads – imported by cPickle, collections

missing module named cPickle.dumps – imported by cPickle, collections

missing module named collections.deque – imported by collections, shlex, threading, Queue

missing module named collections.OrderedDict – imported by collections, unittest.util

missing module named _collections.deque – imported by _collections, collections

missing module named _collections.defaultdict – imported by _collections, collections

missing module named ‘org.python’.imp – imported by ‘org.python’, xml.sax

missing module named ‘org.python’ – imported by pickle, xml.sax

missing module named ‘org.python’.PyStringMap – imported by ‘org.python’, pickle

missing module named java.Exception – imported by java, xml.sax._exceptions

missing module named java – imported by xml.sax._exceptions

missing module named _xmlplus – imported by xml

missing module named threading.RLock – imported by threading, _threading_local

missing module named threading.current_thread – imported by threading, _threading_local

missing module named time.time – imported by time, threading, Queue

missing module named time.sleep – imported by time, threading

missing module named time.ctime – imported by time, PyQt4.uic

missing module named PyQt4.uic.Compiler.qtproxies.LiteralProxyClass – imported by PyQt4.uic.Compiler.qtproxies, PyQt4.uic.Compiler.proxy_metaclass

missing module named PyQt4.uic.port_v3.proxy_base.ProxyBase – imported by PyQt4.uic.port_v3.proxy_base, PyQt4.uic.Compiler.qtproxies

invalid module named PyQt4.uic.port_v3.proxy_base – imported by PyQt4.uic.Compiler.qtproxies

missing module named PySide.QCoreApplication – imported by PySide, Y:\temp\GBDT\Trunk\Src\PyInstaller\loader\rthooks\pyi_rth_qt4plugins.py

missing module named PySide – imported by Y:\temp\GBDT\Trunk\Src\PyInstaller\loader\rthooks\pyi_rth_qt4plugins.py

missing module named _subprocess.STD_OUTPUT_HANDLE – imported by _subprocess, subprocess

missing module named _subprocess.CREATE_NEW_PROCESS_GROUP – imported by _subprocess, subprocess

missing module named _subprocess.STD_INPUT_HANDLE – imported by _subprocess, subprocess

missing module named _subprocess.STARTF_USESHOWWINDOW – imported by _subprocess, subprocess

missing module named _subprocess.CREATE_NEW_CONSOLE – imported by _subprocess, subprocess

missing module named _subprocess.STD_ERROR_HANDLE – imported by _subprocess, subprocess

missing module named _subprocess.STARTF_USESTDHANDLES – imported by _subprocess, subprocess

missing module named _subprocess.SW_HIDE – imported by _subprocess, subprocess

missing module named riscosenviron._Environ – imported by riscosenviron, os

missing module named riscosenviron – imported by os

missing module named riscospath – imported by os

missing module named riscos._exit – imported by riscos, os

missing module named riscos – imported by os

missing module named ce._exit – imported by ce, os

missing module named ce – imported by os

missing module named _emx_link.link – imported by _emx_link, os

missing module named _emx_link – imported by os

missing module named os2._exit – imported by os2, os

missing module named os2 – imported by os

missing module named posix._exit – imported by posix, os

missing module named posix – imported by os

missing module named resource – imported by posix

missing module named sys.modules – imported by sys, dummy_threading

missing module named unicodedata.ucd_3_2_0 – imported by unicodedata, stringprep, encodings.idna

missing module named codecs.mbcs_encode – imported by codecs, encodings.mbcs

missing module named codecs.mbcs_decode – imported by codecs, encodings.mbcs

missing module named Depend – imported by DTDgnModel.GB28181.Diagnostor

missing module named _dummy_threading.__all__ – imported by _dummy_threading, dummy_threading

missing module named _dummy_threading – imported by dummy_threading

搜:

missing module named PyQt4.QtCore.QCoreApplication imported by PyQt4.QtCore

python – PyInstaller error with PyQt when trying to build –onefile – Stack Overflow

把:

import PyQt4.QtCore, PyQt4.QtGui

改为:

from PyQt4 import QtCore, QtGui

去试试

Problem with Python 2.6 and PyQt4 on Windows – Google Groups

python – ImportError: No module named PyQt4.QtCore – Stack Overflow

PyQt4 with Pyinstaller, the EXE fails to run · Issue #1929 · pyinstaller/pyinstaller

Bug #1293948 “Missing dependency on python3-pyqt4” : Bugs : kubuntu-driver-manager package : Ubuntu

pyinstaller  missing module named PyQt4.QtCore.QCoreApplication

看了你的警告:

missing module named math

竟然缺少python默认的math等库

-》感觉是不是:

要么是你python版本安装的有问题了?

-》或者是给的python路径有问题了?

-》否则不太可能会连默认的python的库都找不到啊

是不是要所有的警告解决啦  才能正常啊

不是 但是至少要:确保你调用到的库 都没有警告-》才说明已经正常集成了对应的库-》否则程序没法运行

像math警告我看sitspackages下有这个模块的 不知道为什么还是缺少

可能:

1.python安装了多个版本?

2.python安装后被破坏了?

试试重新安装ptyhon是否可以解决?

3.pyinstaller的参数设置有问题?

另外,把:

-p C:\Python27\Lib\site-packages\PyQt4;C:\Python27\;C:\Python27\Lib;C:\Python27\Lib\site-packages\pywin32_system32

加上引号试试:

-p "C:\Python27\Lib\site-packages\PyQt4;C:\Python27\;C:\Python27\Lib;C:\Python27\Lib\site-packages\pywin32_system32"

以及,

最后一个路径:

C:\Python27\Lib\site-packages\pywin32_system32

后面 加上分号:

C:\Python27\Lib\site-packages\pywin32_system32;

试试

另外

参考:

Using PyInstaller — PyInstaller 3.2 documentation

https://pythonhosted.org/PyInstaller/usage.html

 再加上-d参数 -》输出调试信息 试试-》看看能否输出什么有价值的信息 便于以找到问题原因

好的我先看谢谢了啊  我的python是2.7

另外,我之前的:

【记录】用PyInstaller把Python代码打包成单个独立的exe可执行文件

【记录】用PyInstaller把Python代码打包成单个独立的exe可执行文件

中,加图标的,没有冒号

-i ..\BlogsToWordpress\BlogsToWordpress.ico

你这里有冒号:

–icon="1.ico"

所有的上述的小细节之处 都去试试 看看结果

好的非常感谢

不客气

或者 不知道重现安装pyqt是否有用

不知道这个是不是你要的:

PyQt – Browse /PyQt4/PyQt-4.11.4 at SourceForge.net

https://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.11.4/

PyQt – Browse Files at SourceForge.net

https://sourceforge.net/projects/pyqt/files/

当然 别人也遇到过:

PyQt4 with Pyinstaller, the EXE fails to run · Issue #1929 · pyinstaller/pyinstaller

https://github.com/pyinstaller/pyinstaller/issues/1929

也可以能是pyinstaller本身的bug(虽然可能性不是很大)

missing module named math.sin – imported by math, random

Pyinstaller seems to fail when importing google · Issue #1279 · pyinstaller/pyinstaller

去参考:

If Things Go Wrong · pyinstaller/pyinstaller Wiki

参考:

Using PyInstaller — PyInstaller 3.2 documentation

去看看那个.spec文件是否有异常

再加上–clean试试效果?

加上:

–log-level DEBUG

试试

-》可以输出更多信息 便于看出来问题出在哪

上次说的问题我用-p选项解决啦 多谢了哦

就是把我依赖的模块一个个加到-p选项里去

不加-w编出来的程序在dos下运行能看到错误提示少什么加什么

那就还是需要你自己添加对应的依赖的库

-》为何你之前没有都加上?

之前是加了-w选项界面一运行只是谈出来框不知道哪些缺少

这是个定位方法的问题

另外想问下我这个pythonistaller打包的exe里面用到vlc的动态库   vlc安装目录和exe不在同一目录找不到有什么方法吗

find_library(libvlc.dll)找不到 因为我的exe要给任何人员用 别人电脑上vlc装的路径不一样的

我测试过直接exe运行放码流时视频窗口不能弹出   用py启动是可以的

搜:

pyinstaller dynamic linking

FAQ · pyinstaller/pyinstaller Wiki

Linking against static vs. dynamic libpython – Google Groups

[Tutor] Dynamic linking vs Static linking of libraries in python

python – PyInstaller cannot find libpython2.7.so when making binary? – Stack Overflow

最好能让exe在系统环境变量里找模块就好了

嗯 目前能想到的:

让你运行exe的机器中 把对应的安装路径加入到PATH环境变量中

你自己想办法看看 能否把动态库 也导入到exe中

pyinstaller import dynamic library

思路1:自己想办法把你用到的vlc的库 也继承导入到exe中

思路2:让用你exe的人 自己安装vlc 并且把对应的库的路径 加入到对应的环境变量 (PATH 还是 对应的库的搜索路径) 应该就可以了

转载请注明:在路上 » [已解决]pyinstaller打包exe运行出错:fatal error returned -1

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
101 queries in 0.235 seconds, using 20.26MB memory