加载Python lib pyinstaller时出错(详细说明了不同的尝试)

时间:2020-05-03 20:07:11

标签: python macos pyinstaller

加载Python库时出错 我的python脚本的名称是kled.py

这是我用来创建它的消息:

pyinstaller kled.py-窗口 这是我执行位于dist中的终端文件时收到的错误消息->(一个名为kled的文件夹)->(名为kled的可执行终端文件)

[3173] Error loading Python lib '/Users/john/Documents/chill.py/kledfinal/dist/kled/Python': dlopen: dlopen(/Users/john/Documents/chill.py/kledfinal/dist/kled/Python, 10): no suitable image found.  Did find:
    /Users/john/Documents/chill.py/kledfinal/dist/kled/Python: code signature invalid for '/Users/john/Documents/chill.py/kledfinal/dist/kled/Python'

当我双击创建的应用程序时,它似乎在我的扩展坞中打开,然后消失,实际上没有任何打开。

以下是我已经看过但没有成功的资源:

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

  • 我不理解他们找到的解决方案。这两个故障排除人员没有解释他们正在采取的步骤,因此我无法遵循。

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

  • 这是我更改规范文件的主意,因为在他的pyinstaller命令中,似乎他有一个特定的规范文件正在尝试使用。

https://pyinstaller.readthedocs.io/en/stable/spec-files.html

  • 我想也许我可以编辑自己的规范文件以包含可能缺少的模块或python版本,但是没有其他结果告诉我如何正确设置规范文件来执行此操作。我最初尝试使用py2app,如果您知道的话,您会知道setup.py基本上可以让您手动选择所需的所有文件和内容。不幸的是py2app通常有很多问题,所以我认为我的错误不会得到解决,但是pyinstaller似乎有一些专家,也许你们可以帮忙。

Error loading Python lib with PyInstaller on MacOS

  • 经历了所有步骤,但对我却没有用。如果应用程序无法运行,并且可执行文件终端文件kled的结果相同,则表明加载python lib时出错。

您可能需要的资源(idk我只是在猜测,但这是一些东西)

我的kled.spec文件:

# -*- mode: python ; coding: utf-8 -*-

block_cipher = None


a = Analysis(['kled.py'],
             pathex=['/Users/john/Documents/chill.py/kledfinal'],
             binaries=[],
             datas=[],
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          [],
          name='kled',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          upx_exclude=[],
          runtime_tmpdir=None,
          console=False )
app = BUNDLE(exe,
             name='kled.app',
             icon=None,
             bundle_identifier=None)


**Python version:**

Python 3.8.2

我要使用的模块:

pygame 时间 随机 系统 操作系统 泡菜

MacOS版本:

macOS Catalina

版本10.15.4

我的warn-kled.txt文件:

This file lists modules PyInstaller was not able to find. This does not
necessarily mean this module is required for running you program. Python and
Python 3rd-party packages include a lot of conditional or optional modules. For
example the module 'ntpath' only exists on Windows, whereas the module
'posixpath' only exists on Posix systems.

Types if import:
* top-level: imported at the top-level - look at these first
* conditional: imported within an if-statement
* delayed: imported from within a function
* optional: imported within a try-except-statement

IMPORTANT: Do NOT post this list to the issue-tracker. Use it as a basis for
           yourself tracking down the missing module. Thanks!

missing module named pyimod03_importers - imported by /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/PyInstaller/loader/rthooks/pyi_rth_pkgres.py (top-level)
missing module named StringIO - imported by setuptools._vendor.six (conditional), numpy.testing._private.utils (conditional), numpy.lib.utils (delayed, conditional), numpy.lib.format (delayed, conditional), pkg_resources._vendor.six (conditional), py._io.capture (optional)
missing module named 'pkg_resources.extern.pyparsing' - imported by pkg_resources._vendor.packaging.markers (top-level), pkg_resources._vendor.packaging.requirements (top-level)
missing module named 'win32com.shell' - imported by pkg_resources._vendor.appdirs (conditional, optional)
missing module named 'com.sun' - imported by pkg_resources._vendor.appdirs (delayed, conditional, optional)
missing module named com - imported by pkg_resources._vendor.appdirs (delayed)
missing module named nt - imported by os (delayed, conditional, optional), ntpath (optional), shutil (conditional), pathlib (conditional), ctypes (delayed, conditional)
missing module named win32api - imported by distutils.msvccompiler (optional), pkg_resources._vendor.appdirs (delayed, conditional, optional)
missing module named win32com - imported by pkg_resources._vendor.appdirs (delayed)
missing module named _winreg - imported by platform (delayed, optional), pygame.sysfont (conditional), numpy.distutils.cpuinfo (delayed, conditional, optional), pkg_resources._vendor.appdirs (delayed, conditional), pygments.formatters.img (optional)
missing module named winreg - imported by platform (delayed, optional), mimetypes (optional), urllib.request (delayed, conditional, optional), pygame.sysfont (conditional), distutils.msvccompiler (optional), distutils.msvc9compiler (top-level), distutils._msvccompiler (top-level), numpy.distutils.cpuinfo (delayed, conditional, optional), pkg_resources._vendor.appdirs (delayed, conditional), pygments.formatters.img (optional)
missing module named netbios - imported by uuid (delayed)
missing module named win32wnet - imported by uuid (delayed)
missing module named _winapi - imported by encodings (delayed, conditional, optional), subprocess (optional), test.support (delayed, conditional), multiprocessing.connection (optional), multiprocessing.spawn (delayed, conditional), multiprocessing.reduction (conditional), multiprocessing.shared_memory (conditional), multiprocessing.heap (conditional), multiprocessing.popen_spawn_win32 (top-level), asyncio.windows_events (top-level), asyncio.windows_utils (top-level)
missing module named msvcrt - imported by subprocess (optional), getpass (optional), test.support (delayed, conditional, optional), multiprocessing.spawn (delayed, conditional), multiprocessing.popen_spawn_win32 (top-level), asyncio.windows_events (top-level), asyncio.windows_utils (top-level), numpy.distutils.mingw32ccompiler (conditional, optional)
missing module named urllib.urlretrieve - imported by urllib (conditional, optional), pygments.lexers._php_builtins (conditional, optional)
missing module named urllib.FancyURLopener - imported by urllib (conditional, optional), pygments.lexers._sourcemod_builtins (conditional, optional)
missing module named urllib.urlopen - imported by urllib (conditional, optional), pygments.lexers._postgres_builtins (conditional, optional), pygments.lexers._lua_builtins (conditional, optional)
missing module named urllib.quote - imported by urllib (delayed), py._path.svnwc (delayed)
missing module named _frozen_importlib_external - imported by importlib._bootstrap (delayed), importlib (optional), importlib.abc (optional), zipimport (top-level)
excluded module named _frozen_importlib - imported by importlib (optional), importlib.abc (optional), zipimport (top-level)
missing module named __builtin__ - imported by numpy.core.numerictypes (conditional), numpy.core.numeric (conditional), numpy.lib.function_base (conditional), numpy.lib._iotools (conditional), numpy.ma.core (conditional), numpy.distutils.misc_util (delayed, conditional), numpy (conditional), pkg_resources._vendor.pyparsing (conditional), setuptools._vendor.pyparsing (conditional), py._builtin (conditional), ptyprocess.ptyprocess (optional)
missing module named ordereddict - imported by pkg_resources._vendor.pyparsing (optional), setuptools._vendor.pyparsing (optional)
missing module named 'org.python' - imported by copy (optional), setuptools.sandbox (conditional), xml.sax (delayed, conditional)
missing module named multiprocessing.TimeoutError - imported by multiprocessing (top-level), multiprocessing.pool (top-level)
missing module named multiprocessing.get_context - imported by multiprocessing (top-level), multiprocessing.pool (top-level), multiprocessing.managers (top-level), multiprocessing.sharedctypes (top-level)
missing module named multiprocessing.set_start_method - imported by multiprocessing (top-level), multiprocessing.spawn (top-level)
missing module named multiprocessing.get_start_method - imported by multiprocessing (top-level), multiprocessing.spawn (top-level)
missing module named 'java.lang' - imported by platform (delayed, optional), xml.sax._exceptions (conditional)
missing module named multiprocessing.BufferTooShort - imported by multiprocessing (top-level), multiprocessing.connection (top-level)
missing module named multiprocessing.AuthenticationError - imported by multiprocessing (top-level), multiprocessing.connection (top-level)
missing module named _overlapped - imported by asyncio.windows_events (top-level)
missing module named asyncio.DefaultEventLoopPolicy - imported by asyncio (delayed, conditional), asyncio.events (delayed, conditional)
missing module named win32evtlog - imported by logging.handlers (delayed, optional)
missing module named win32evtlogutil - imported by logging.handlers (delayed, optional)
missing module named pkg_resources.extern.packaging - imported by pkg_resources.extern (top-level), pkg_resources (top-level)
missing module named pkg_resources.extern.appdirs - imported by pkg_resources.extern (top-level), pkg_resources (top-level)
missing module named 'pkg_resources.extern.six.moves' - imported by pkg_resources (top-level), pkg_resources._vendor.packaging.requirements (top-level)
missing module named pkg_resources.extern.six - imported by pkg_resources.extern (top-level), pkg_resources (top-level), pkg_resources.py31compat (top-level)
missing module named vms_lib - imported by platform (delayed, conditional, optional)
missing module named java - imported by platform (delayed)
missing module named 'multiprocessing.forking' - imported by /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/PyInstaller/loader/rthooks/pyi_rth_multiprocessing.py (optional)
missing module named org - imported by pickle (optional)
missing module named copy_reg - imported by cStringIO (top-level), numpy.core (conditional), pygame (conditional)
missing module named 'pygame._view' - imported by pygame (delayed)
missing module named OpenGL - imported by pygame (delayed)
missing module named numpy.uint32 - imported by numpy (top-level), pygame._numpysurfarray (top-level)
missing module named commands - imported by numpy.distutils.cpuinfo (conditional)
missing module named setuptools.extern.packaging - imported by setuptools.extern (top-level), setuptools.dist (top-level), setuptools.command.egg_info (top-level)
missing module named 'setuptools.extern.six' - imported by setuptools (top-level), setuptools.extension (top-level)
missing module named 'setuptools.extern.packaging.specifiers' - imported by setuptools.config (top-level)
missing module named 'setuptools.extern.packaging.version' - imported by setuptools.config (top-level), setuptools.msvc (top-level)
missing module named setuptools.extern.six.moves.filterfalse - imported by setuptools.extern.six.moves (top-level), setuptools.dist (top-level), setuptools.msvc (top-level)
missing module named setuptools.extern.six.moves.filter - imported by setuptools.extern.six.moves (top-level), setuptools.dist (top-level), setuptools.ssl_support (top-level), setuptools.command.py36compat (top-level)
missing module named setuptools.extern.ordered_set - imported by setuptools.extern (top-level), setuptools.dist (top-level), setuptools.command.sdist (top-level)
missing module named 'setuptools.extern.packaging.utils' - imported by setuptools.wheel (top-level)
missing module named 'setuptools.extern.packaging.tags' - imported by setuptools.wheel (top-level)
missing module named wincertstore - imported by setuptools.ssl_support (delayed, optional)
missing module named 'backports.ssl_match_hostname' - imported by setuptools.ssl_support (optional)
missing module named backports - imported by setuptools.ssl_support (optional)
missing module named 'setuptools._vendor.six.moves' - imported by 'setuptools._vendor.six.moves' (top-level)
missing module named 'setuptools.extern.pyparsing' - imported by setuptools._vendor.packaging.requirements (top-level), setuptools._vendor.packaging.markers (top-level)
missing module named setuptools.extern.six.moves.winreg - imported by setuptools.extern.six.moves (conditional), setuptools.msvc (conditional)
missing module named setuptools.extern.six.moves.map - imported by setuptools.extern.six.moves (top-level), setuptools.dist (top-level), setuptools.command.easy_install (top-level), setuptools.sandbox (top-level), setuptools.package_index (top-level), setuptools.ssl_support (top-level), setuptools.command.egg_info (top-level), setuptools.namespaces (top-level)
runtime module named setuptools.extern.six.moves - imported by setuptools.dist (top-level), configparser (top-level), setuptools.command.easy_install (top-level), setuptools.sandbox (top-level), setuptools.command.setopt (top-level), setuptools.package_index (top-level), setuptools.ssl_support (top-level), setuptools.py33compat (top-level), setuptools.command.egg_info (top-level), setuptools.command.py36compat (top-level), setuptools.namespaces (top-level), setuptools.msvc (top-level), 'setuptools._vendor.six.moves' (top-level)
missing module named setuptools.extern.six - imported by setuptools.extern (top-level), setuptools.monkey (top-level), setuptools.dist (top-level), setuptools.extern.six.moves (top-level), setuptools.config (top-level), setuptools.command.easy_install (top-level), setuptools.sandbox (top-level), setuptools.py27compat (top-level), setuptools.package_index (top-level), setuptools.py33compat (top-level), setuptools.wheel (top-level), setuptools.command.egg_info (top-level), setuptools.command.sdist (top-level), setuptools.command.bdist_egg (top-level), setuptools.unicode_utils (top-level), setuptools.installer (top-level), setuptools.command.develop (top-level)
missing module named 'numpy_distutils.cpuinfo' - imported by numpy.f2py.diagnose (delayed, conditional, optional)
missing module named 'numpy_distutils.fcompiler' - imported by numpy.f2py.diagnose (delayed, conditional, optional)
missing module named 'numpy_distutils.command' - imported by numpy.f2py.diagnose (delayed, conditional, optional)
missing module named numpy_distutils - imported by numpy.f2py.diagnose (delayed, optional)
missing module named __svn_version__ - imported by numpy.f2py.__version__ (optional)
missing module named numarray - imported by numpy.distutils.system_info (delayed, conditional, optional)
missing module named Numeric - imported by numpy.distutils.system_info (delayed, conditional, optional)
missing module named ConfigParser - imported by numpy.distutils.system_info (conditional), numpy.distutils.npy_pkg_config (conditional)
missing module named win32con - imported by distutils.msvccompiler (optional)
missing module named _dummy_threading - imported by dummy_threading (optional)
missing module named twisted - imported by _pytest.unittest (delayed)
missing module named zope - imported by _pytest.unittest (delayed)
missing module named py.process - imported by py (top-level), py._path.svnurl (top-level)
missing module named py.path - imported by py (top-level), py._path.svnurl (top-level), _pytest.doctest (top-level)
missing module named apipkg - imported by py (optional)
missing module named UserDict - imported by attr._compat (conditional)
missing module named chardet - imported by pygments.lexer (delayed, conditional, optional)
missing module named ctags - imported by pygments.formatters.html (optional)
missing module named PIL - imported by pygments.formatters.img (optional)
missing module named 'py.io' - imported by _pytest._io (top-level)
missing module named importlib_metadata - imported by pluggy.manager (conditional), _pytest.compat (conditional)
missing module named typing_extensions - imported by _pytest.outcomes (conditional), _pytest._code.code (conditional), _pytest._code.source (conditional), _pytest.config.argparsing (conditional), _pytest.runner (conditional), _pytest.main (conditional), _pytest.capture (conditional)
missing module named pathlib2 - imported by _pytest.pathlib (conditional)
missing module named colorama - imported by py._io.terminalwriter (conditional, optional), _pytest.capture (delayed, conditional, optional)
missing module named atomicwrites - imported by _pytest.assertion.rewrite (conditional)
missing module named argcomplete - imported by _pytest._argcomplete (conditional, optional)
missing module named 'py.builtin' - imported by py._io.terminalwriter (top-level)
missing module named compiler - imported by py._code._assertionold (top-level)
missing module named 'nose.plugins' - imported by numpy.testing._private.noseclasses (top-level), numpy.testing._private.nosetester (delayed)
missing module named scipy - imported by numpy.testing._private.nosetester (delayed, conditional)
missing module named 'nose.util' - imported by numpy.testing._private.noseclasses (top-level)
missing module named nose - imported by numpy.testing._private.utils (delayed, optional), numpy.testing._private.decorators (delayed), numpy.testing._private.noseclasses (top-level)
missing module named psutil - imported by numpy.testing._private.utils (delayed, optional)
missing module named numpy.core.number - imported by numpy.core (delayed), numpy.testing._private.utils (delayed)
missing module named numpy.core.object_ - imported by numpy.core (top-level), numpy.linalg.linalg (top-level), numpy.testing._private.utils (delayed)
missing module named numpy.core.signbit - imported by numpy.core (delayed), numpy.testing._private.utils (delayed)
missing module named win32pdh - imported by numpy.testing._private.utils (delayed, conditional)
missing module named numpy.core.float32 - imported by numpy.core (top-level), numpy.testing._private.utils (top-level)
missing module named numpy.core.intp - imported by numpy.core (top-level), numpy.testing._private.utils (top-level), numpy.linalg.linalg (top-level)
missing module named numpy.lib.i0 - imported by numpy.lib (top-level), numpy.dual (top-level)
missing module named dummy_thread - imported by numpy.core.arrayprint (conditional, optional)
missing module named thread - imported by numpy.core.arrayprint (conditional, optional)
missing module named cpickle - imported by numpy.compat.py3k (conditional)
missing module named pickle5 - imported by numpy.compat.py3k (conditional, optional)
missing module named numpy.core.integer - imported by numpy.core (top-level), numpy.fft.helper (top-level)
missing module named numpy.core.sqrt - imported by numpy.core (top-level), numpy.linalg.linalg (top-level), numpy.fft._pocketfft (top-level)
missing module named numpy.core.conjugate - imported by numpy.core (top-level), numpy.fft._pocketfft (top-level)
missing module named numpy.core.sign - imported by numpy.core (top-level), numpy.linalg.linalg (top-level)
missing module named numpy.core.divide - imported by numpy.core (top-level), numpy.linalg.linalg (top-level)
missing module named numpy.core.geterrobj - imported by numpy.core (top-level), numpy.linalg.linalg (top-level)
missing module named numpy.core.add - imported by numpy.core (top-level), numpy.linalg.linalg (top-level)
missing module named numpy.core.complexfloating - imported by numpy.core (top-level), numpy.linalg.linalg (top-level)
missing module named numpy.core.inexact - imported by numpy.core (top-level), numpy.linalg.linalg (top-level)
missing module named numpy.core.cdouble - imported by numpy.core (top-level), numpy.linalg.linalg (top-level)
missing module named numpy.core.csingle - imported by numpy.core (top-level), numpy.linalg.linalg (top-level)
missing module named numpy.core.double - imported by numpy.core (top-level), numpy.linalg.linalg (top-level)
missing module named numpy.core.single - imported by numpy.core (top-level), numpy.linalg.linalg (top-level)
missing module named future_builtins - imported by numpy.lib.npyio (conditional)
missing module named urllib2 - imported by numpy.lib._datasource (delayed, conditional)
missing module named urlparse - imported by numpy.lib._datasource (delayed, conditional)
missing module named numpy.recarray - imported by numpy (top-level), numpy.ma.mrecords (top-level)
missing module named numpy.dtype - imported by numpy (top-level), numpy.ma.mrecords (top-level), numpy.ctypeslib (top-level)
missing module named numpy.expand_dims - imported by numpy (top-level), numpy.ma.core (top-level)
missing module named numpy.array - imported by numpy (top-level), numpy.ma.core (top-level), numpy.ma.extras (top-level), numpy.ma.mrecords (top-level), numpy.ctypeslib (top-level), pygame._numpysurfarray (top-level)
missing module named numpy.bool_ - imported by numpy (top-level), numpy.ma.core (top-level), numpy.ma.mrecords (top-level)
missing module named numpy.iscomplexobj - imported by numpy (top-level), numpy.ma.core (top-level)
missing module named numpy.amin - imported by numpy (top-level), numpy.ma.core (top-level)
missing module named numpy.amax - imported by numpy (top-level), numpy.ma.core (top-level)
missing module named numpy.ndarray - imported by numpy (top-level), numpy.ma.core (top-level), numpy.ma.extras (top-level), numpy.ma.mrecords (top-level), numpy.ctypeslib (top-level), pygame._numpysurfarray (top-level)
missing module named numpy.histogramdd - imported by numpy (delayed), numpy.lib.twodim_base (delayed)
missing module named numpy.eye - imported by numpy (delayed), numpy.core.numeric (delayed)
missing module named 'pygame.scrap' - imported by pygame (optional)
missing module named 'pygame.movie' - imported by pygame (optional)
missing module named 'pygame.overlay' - imported by pygame (optional)
missing module named Queue - imported by pygame.threads (conditional)
missing module named Py25Queue - imported by pygame.threads (conditional)
missing module named 'pygame.cdrom' - imported by pygame (conditional, optional)
missing module named cStringIO - imported by pygame.compat (conditional)

1 个答案:

答案 0 :(得分:1)

最新的Pyinstaller(版本3.6)仅支持Python 2.7、3.5–3.7

因此,降级Python3.8一切正常。