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__, tarfilemissing module named unicodedata.ucd_3_2_0 - imported by unicodedata, stringprep, encodings.idnamissing module named _sre.MAXREPEAT - imported by _sre, sre_constantsmissing module named _warnings.warn_explicit - imported by _warnings, warningsmissing module named _warnings.filters - imported by _warnings, warningsmissing module named _warnings.once_registry - imported by _warnings, warningsmissing module named _warnings.default_action - imported by _warnings, warningsmissing module named _warnings.warn - imported by _warnings, warningsmissing module named itertools.islice - imported by itertools, repr, heapqmissing module named itertools.starmap - imported by itertools, collections
missing module named itertools.repeat - imported by itertools, collectionsmissing module named itertools.imap - imported by itertools, heapq, collectionsmissing module named itertools.tee - imported by itertools, heapqmissing module named itertools.izip - imported by itertools, heapqmissing module named itertools.count - imported by itertools, heapq, threadingmissing module named itertools.chain - imported by itertools, tokenize, heapq, collectionsmissing module named org.PyStringMap - imported by org, copymissing module named org - imported by copymissing module named exceptions.ReferenceError - imported by exceptions, weakrefmissing module named _weakref.ref - imported by _weakref, _weakrefset, weakref
missing module named _weakref.ReferenceType - imported by _weakref, weakrefmissing module named _weakref.proxy - imported by _weakref, weakrefmissing module named _weakref.getweakrefs - imported by _weakref, weakrefmissing module named _weakref.getweakrefcount - imported by _weakref, weakrefmissing module named _weakref.ProxyType - imported by _weakref, weakrefmissing module named _weakref.CallableProxyType - imported by _weakref, weakrefmissing module named copy.deepcopy - imported by copy, weakrefmissing module named re._compile - imported by re, sremissing module named re.__all__ - imported by re, sremissing module named codecs.mbcs_encode - imported by codecs, encodings.mbcs
missing module named codecs.mbcs_decode - imported by codecs, encodings.mbcsmissing module named binascii.b2a_qp - imported by binascii, quoprimissing module named binascii.a2b_qp - imported by binascii, quoprimissing module named binascii.a2b_uu - imported by binascii, encodings.uu_codecmissing module named binascii.b2a_uu - imported by binascii, encodings.uu_codecmissing module named binascii.hexlify - imported by binascii, randommissing module named errno.EINVAL - imported by errno, StringIOmissing module named errno.ENOENT - imported by errno, gettextmissing module named cStringIO.StringIO - imported by cStringIO, gettext, pprint, shlex, tempfile, pickle, tarfile, encodings.uu_codec, quopri, encodings.quopri_codecmissing module named _struct.__doc__ - imported by _struct, struct
missing module named _struct._clearcache - imported by _struct, structmissing module named strop.whitespace - imported by strop, stringmissing module named strop.maketrans - imported by strop, stringmissing module named strop.lowercase - imported by strop, stringmissing module named strop.uppercase - imported by strop, stringmissing module named collections.OrderedDict - imported by collections, unittest.util, ConfigParsermissing module named fcntl - imported by tempfile, subprocessmissing module named time.time - imported by time, threadingmissing module named time.sleep - imported by time, threadingmissing module named thread.allocate_lock - imported by thread, _strptime
missing module named datetime.date - imported by datetime, _strptimemissing module named _functools.partial - imported by _functools, functoolsmissing module named _functools.reduce - imported by _functools, functoolsmissing module named _hashlib.pbkdf2_hmac - imported by _hashlib, hashlibmissing module named threading.RLock - imported by threading, _threading_localmissing module named threading.current_thread - imported by threading, _threading_localmissing module named thread._local - imported by thread, threadingmissing module named thread.stack_size - imported by thread, threadingmissing module named os.urandom - imported by os, randommissing module named math.sin - imported by math, random
missing module named math.sqrt - imported by math, randommissing module named math.cos - imported by math, randommissing module named math.acos - imported by math, randommissing module named math.ceil - imported by math, randommissing module named math.exp - imported by math, randommissing module named math.log - imported by math, randommissing module named math.e - imported by math, randommissing module named math.pi - imported by math, randommissing module named _io.DEFAULT_BUFFER_SIZE - imported by _io, iomissing module named _io.BytesIO - imported by _io, io
missing module named _io.open - imported by _io, iomissing module named _io.BufferedWriter - imported by _io, iomissing module named _io.FileIO - imported by _io, iomissing module named _io.BlockingIOError - imported by _io, iomissing module named _io.IncrementalNewlineDecoder - imported by _io, iomissing module named _io.BufferedReader - imported by _io, iomissing module named _io.BufferedRandom - imported by _io, iomissing module named _io.StringIO - imported by _io, iomissing module named _io.BufferedRWPair - imported by _io, iomissing module named _io.TextIOWrapper - imported by _io, io
missing module named _io.UnsupportedOperation - imported by _io, iomissing module named readline - imported by cmd, pdbmissing module named pwd - imported by posixpath, shutil, tarfilemissing module named pwd.getpwnam - imported by pwd, shutilmissing module named operator.attrgetter - imported by operator, inspectmissing module named cPickle.loads - imported by cPickle, collectionsmissing module named cPickle.dumps - imported by cPickle, collectionsmissing module named thread.get_ident - imported by thread, collectionsmissing module named collections.deque - imported by collections, shlex, threadingmissing module named collections.namedtuple - imported by collections, inspect, unittest.util, difflib, doctestmissing module named operator.itemgetter - imported by operator, collections, heapqmissing module named operator.eq - imported by operator, collectionsmissing module named _collections.deque - imported by _collections, collectionsmissing module named _collections.defaultdict - imported by _collections, collectionsmissing module named nt._isdir - imported by nt, ntpathmissing module named nt._getfullpathname - imported by nt, ntpathmissing module named nt._exit - imported by nt, osmissing module named _sysconfigdata.build_time_vars - imported by _sysconfigdata, distutils.sysconfigmissing module named _sysconfigdata - imported by distutils.sysconfigmissing module named grp.getgrnam - imported by grp, shutilmissing module named grp - imported by shutil, tarfilemissing module named _subprocess.STD_OUTPUT_HANDLE - imported by _subprocess, subprocessmissing module named _subprocess.CREATE_NEW_PROCESS_GROUP - imported by _subprocess, subprocessmissing module named _subprocess.STD_INPUT_HANDLE - imported by _subprocess, subprocessmissing module named _subprocess.STARTF_USESHOWWINDOW - imported by _subprocess, subprocessmissing module named _subprocess.CREATE_NEW_CONSOLE - imported by _subprocess, subprocessmissing module named _subprocess.STD_ERROR_HANDLE - imported by _subprocess, subprocessmissing module named _subprocess.STARTF_USESTDHANDLES - imported by _subprocess, subprocessmissing module named _subprocess.SW_HIDE - imported by _subprocess, subprocessmissing module named org.python.PyStringMap - imported by org.python, picklemissing module named org.python - imported by picklemissing module named riscosenviron._Environ - imported by riscosenviron, osmissing module named riscosenviron - imported by osmissing module named riscospath - imported by osmissing module named riscos._exit - imported by riscos, osmissing module named riscos - imported by osmissing module named ce._exit - imported by ce, osmissing module named ce - imported by osmissing module named _emx_link.link - imported by _emx_link, osmissing module named _emx_link - imported by osmissing module named os2._exit - imported by os2, osmissing module named os2 - imported by osmissing module named posix._exit - imported by posix, osmissing module named posix - imported by osmissing 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 |