Pyinstaller打包後運行,程序一閃而過,怎麼解決?

環境32位win7用一個腳本包含 Pmw,numpy,matplot,tkintertable 的包,然後是一個 TKinter GUI 界面的成一個程序,打包後,一閃而過,是怎麼回事?打包指令加了 -w -F -P跟上了以上所有包的lib地址,然後總是運行不起來


python 3.5+pyinstaller 3.2+matplotlib 無法打包成功,原因在於圖形庫無法正常打包,Qt5, tkinter等均不行。目前好像還解決不了啊。


把exe拖入cmd界面再執行。會列印出錯信息。然後自己排查吧。


我最近也在弄pyinstaller打包,雙擊一閃而過,說明打包有錯誤,具體看build文件下的warn***.txt文檔,裡面詳細記載了錯誤的原因。一般都是庫丟失。


我也是用pyinstaller生成的exe,雙擊運行一閃而過,warn文件夾很多條,不知道哪些是需要加的啊?

如下:

missing module named __builtin__.open - imported by __builtin__, tarfile

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

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

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 itertools.islice - imported by itertools, repr, heapq

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.count - imported by itertools, heapq, threading

missing module named itertools.chain - imported by itertools, tokenize, heapq, collections

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

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

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

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 binascii.b2a_qp - imported by binascii, quopri

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

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.hexlify - imported by binascii, random

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, gettext, pprint, shlex, tempfile, pickle, tarfile, encodings.uu_codec, quopri, encodings.quopri_codec

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

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

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 collections.OrderedDict - imported by collections, unittest.util, ConfigParser

missing module named fcntl - imported by tempfile, subprocess

missing module named time.time - imported by time, threading

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

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

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

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

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

missing module named _hashlib.pbkdf2_hmac - imported by _hashlib, hashlib

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

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

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

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

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 _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 readline - imported by cmd, pdb

missing module named pwd - imported by posixpath, shutil, tarfile

missing module named pwd.getpwnam - imported by pwd, shutil

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

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

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

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

missing module named collections.deque - imported by collections, shlex, threading

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

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

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

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

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

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 _sysconfigdata.build_time_vars - imported by _sysconfigdata, distutils.sysconfig

missing module named _sysconfigdata - imported by distutils.sysconfig

missing module named grp.getgrnam - imported by grp, shutil

missing module named grp - imported by shutil, tarfile

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 org.python.PyStringMap - imported by org.python, pickle

missing module named org.python - imported by pickle

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


如果是cmd窗口那種,直接在主程序最後一行添加raw_input(),之後在試試,先寫個簡單的命令窗print函數試試吧


missing module named resource - imported by posix, C:Users83824Desktoperic-filelogin.py

missing module named posix - imported by os, C:Users83824Desktoperic-filelogin.py

missing module named _posixsubprocess - imported by subprocess, C:Users83824Desktoperic-filelogin.py

missing module named org.python - imported by pickle, C:Users83824Desktoperic-filelogin.py, xml.sax

missing module named ce - imported by os, C:Users83824Desktoperic-filelogin.py

missing module named readline - imported by cmd, code, pdb, C:Users83824Desktoperic-filelogin.py

excluded module named _frozen_importlib - imported by importlib, importlib.abc, C:Users83824Desktoperic-filelogin.py

missing module named _frozen_importlib_external - imported by importlib._bootstrap, importlib, importlib.abc, C:Users83824Desktoperic-filelogin.py

missing module named _winreg - imported by platform, C:Users83824Desktoperic-filelogin.py

missing module named _scproxy - imported by urllib.request

missing module named java - imported by platform, C:Users83824Desktoperic-filelogin.py

missing module named java.lang - imported by platform, C:Users83824Desktoperic-filelogin.py, xml.sax._exceptions

missing module named vms_lib - imported by platform, C:Users83824Desktoperic-filelogin.py

missing module named termios - imported by tty, C:Users83824Desktoperic-filelogin.py, getpass

missing module named grp - imported by shutil, tarfile, C:Users83824Desktoperic-filelogin.py

missing module named _dummy_threading - imported by dummy_threading, C:Users83824Desktoperic-filelogin.py

missing module named org - imported by copy, C:Users83824Desktoperic-filelogin.py

missing module named pwd - imported by posixpath, shutil, tarfile, http.server, webbrowser, C:Users83824Desktoperic-filelogin.py, netrc, getpass

然後報錯是Traceback (most recent call last):

File "eric-filelogin.py", line 6, in &

File "c:users83824anaconda3libsite-packagesPyInstallerloaderpyimod03_importers.py", line 714, in load_module

module = loader.load_module(fullname)

ImportError: DLL load failed: 找不到指定的程序。

[6288] Failed to execute script login 求解怎麼辦?


我最近用Python 3.6和PyQt 5.8.2寫了一個Mac OS X 平台的GUI應用,用PyInstaller 3.2.1打包後運行也是一閃而過,後來用排除法才搞定。

出現這個問題的可能原因:

1)程序中使用到了配置文件、ui設計文件等,打包沒有把它們添加進去。

2)打包時添加了配置文件、ui設計文件等,但是程序打包後運行時會解壓到臨時目錄,導致不能正確讀取到這些文件。

3)打包命令沒有添加好依賴路徑。


寫個點bat文件,裡面寫上要運行的EXE文件名在加上pause就好了至於樓上哥們說的截圖 我只能說厲害了word哥。


看看是不是中文目錄


上面說的在主程序後面加一行raw_input()是可行的,表示運行結束等待回車輸入再退出。


請用Pyinstaller3.1!!!!!!!

3.2是坑!!!!!!


執行的時候截圖就OK了。雖然很快,但是只要手速快截圖後就能看到了。


推薦閱讀:

敢來挑戰嗎——你能想到多少種創建Python對象的方法?
給妹子講python--15迭代環境
Python工程師面試必備25條Python知識點

TAG:Python | Pyinstaller |