使用PyInstaller将python 3.7脚本转换为exe时出错:ModuleNotFoundError

时间:2019-03-03 13:11:14

标签: python python-3.x pygame exe pyinstaller

我已经在python 3.7中创建了一个游戏,我想将其转换为可执行文件。我尝试了py2exe,但它不支持3.7。然后我尝试了PyInstaller。首先,它不是在构建exe文件。然后在以下两个答案中建议进行更改:An error for generating an exe file using pyinstaller - typeerror: expected str, bytes or os.PathLike object, not NoneType

我从build文件夹中打开exe时出现错误,提示加载python dll时出错。 dist文件夹中的exe会在打开时关闭。所以我做了如下修改:https://stackoverflow.com/a/43762970/10058326

这导致build文件夹中没有exe文件,而dist文件夹中的exe文件显示:

error #2

这些是生成的警告:

`missing module named 'multiprocessing.forking' - imported by C:\Users\Kunj\PycharmProjects\Alien Shooter\venv\lib\site-packages\PyInstaller\loader\rthooks\pyi_rth_multiprocessing.py (optional)
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.TimeoutError - imported by multiprocessing (top-level), multiprocessing.pool (top-level)
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 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 'win32com.gen_py' - imported by win32com (conditional, optional), C:\Users\Kunj\PycharmProjects\Alien Shooter\venv\lib\site-packages\PyInstaller\loader\rthooks\pyi_rth_win32comgenpy.py (top-level)
missing module named win32trace - imported by win32com.server.dispatcher (optional)
missing module named win32traceutil - imported by win32com.server.dispatcher (delayed, conditional)
missing module named win32con - imported by win32com.client.selecttlb (top-level), win32com.server.policy (top-level), win32com.util (top-level)
missing module named winerror - imported by win32com.client.dynamic (top-level), win32com.client.build (top-level), win32com.client (delayed, conditional, optional), win32com.server.policy (top-level), win32com.server.util (top-level)
missing module named 'pywin.dialogs' - imported by win32com.client.makepy (delayed, conditional)
missing module named pywin - imported by win32com.client.selecttlb (delayed), win32com.client.makepy (delayed)
missing module named win32ui - imported by win32com.client.makepy (delayed)
missing module named pywintypes - imported by win32com.client.build (top-level), win32com.client.dynamic (top-level), win32com.client.gencache (top-level), win32com.client (top-level), win32com.server.policy (top-level)
missing module named pythoncom - imported by win32com (top-level), win32com.client (top-level), win32com.client.dynamic (top-level), win32com.client.build (top-level), win32com.client.util (top-level), win32com.client.gencache (top-level), win32com.client.makepy (top-level), win32com.client.genpy (top-level), win32com.client.selecttlb (top-level), win32com.server.util (top-level), win32com.server.policy (top-level), win32com.server.exception (top-level), win32com.util (top-level), win32com.universal (top-level), win32com.server.dispatcher (top-level)
missing module named win32api - imported by win32com (top-level), pkg_resources._vendor.appdirs (delayed, conditional, optional), win32com.client.selecttlb (top-level), win32com.server.policy (top-level), win32com.util (top-level), win32com.server.dispatcher (top-level)
missing module named pyimod03_importers - imported by C:\Users\Kunj\PycharmProjects\Alien Shooter\venv\lib\site-packages\PyInstaller\loader\rthooks\pyi_rth_pkgres.py (top-level)
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 'pkg_resources.extern.pyparsing' - imported by pkg_resources._vendor.packaging.requirements (top-level), pkg_resources._vendor.packaging.markers (top-level)
missing module named StringIO - imported by pkg_resources._vendor.six (conditional)
missing module named _uuid - imported by uuid (optional)
missing module named netbios - imported by uuid (delayed)
missing module named win32wnet - imported by uuid (delayed)
missing module named __builtin__ - imported by pkg_resources._vendor.pyparsing (conditional)
missing module named ordereddict - imported by pkg_resources._vendor.pyparsing (optional)
missing module named __main__ - imported by pkg_resources (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)
missing module named resource - imported by posix (top-level), C:\Users\Kunj\PycharmProjects\Alien Shooter\alien_shooter.py (top-level)
missing module named posix - imported by os (conditional, optional), C:\Users\Kunj\PycharmProjects\Alien Shooter\alien_shooter.py (top-level)
missing module named _posixsubprocess - imported by subprocess (conditional), multiprocessing.util (delayed), C:\Users\Kunj\PycharmProjects\Alien Shooter\alien_shooter.py (top-level)
missing module named 'org.python' - imported by pickle (optional), C:\Users\Kunj\PycharmProjects\Alien Shooter\alien_shooter.py (top-level), xml.sax (delayed, conditional)
missing module named readline - imported by cmd (delayed, conditional, optional), code (delayed, conditional, optional), pdb (delayed, optional), C:\Users\Kunj\PycharmProjects\Alien Shooter\alien_shooter.py (top-level)
excluded module named _frozen_importlib - imported by importlib (optional), importlib.abc (optional), C:\Users\Kunj\PycharmProjects\Alien Shooter\alien_shooter.py (top-level)
missing module named _frozen_importlib_external - imported by importlib._bootstrap (delayed), importlib (optional), importlib.abc (optional), C:\Users\Kunj\PycharmProjects\Alien Shooter\alien_shooter.py (top-level)
missing module named _winreg - imported by platform (delayed, optional), pygame (conditional), pygame.sysfont (conditional), C:\Users\Kunj\PycharmProjects\Alien Shooter\alien_shooter.py (top-level), pkg_resources._vendor.appdirs (delayed)
missing module named _scproxy - imported by urllib.request (conditional)
missing module named java - imported by platform (delayed), C:\Users\Kunj\PycharmProjects\Alien Shooter\alien_shooter.py (top-level)
missing module named 'java.lang' - imported by platform (delayed, optional), C:\Users\Kunj\PycharmProjects\Alien Shooter\alien_shooter.py (top-level), xml.sax._exceptions (conditional)
missing module named vms_lib - imported by platform (delayed, conditional, optional), C:\Users\Kunj\PycharmProjects\Alien Shooter\alien_shooter.py (top-level)
missing module named termios - imported by tty (top-level), C:\Users\Kunj\PycharmProjects\Alien Shooter\alien_shooter.py (top-level), getpass (optional)
missing module named grp - imported by shutil (optional), tarfile (optional), C:\Users\Kunj\PycharmProjects\Alien Shooter\alien_shooter.py (top-level)
missing module named org - imported by copy (optional), C:\Users\Kunj\PycharmProjects\Alien Shooter\alien_shooter.py (top-level)
missing module named pwd - imported by posixpath (delayed, conditional), shutil (optional), tarfile (optional), http.server (delayed, optional), webbrowser (delayed), distutils.util (delayed, conditional), C:\Users\Kunj\PycharmProjects\Alien Shooter\alien_shooter.py (top-level), netrc (delayed, conditional), getpass (delayed)
missing module named copy_reg - imported by cStringIO (top-level), pygame (conditional)
missing module named 'pygame._view' - imported by pygame (delayed)
missing module named pygame.sdlmain_osx - imported by pygame (top-level), pygame.macosx (top-level)
missing module named OpenGL - imported by pygame (delayed)
missing module named numpy - imported by pygame._numpysurfarray (top-level), pygame._numpysndarray (top-level), pygame (delayed)
missing module named 'pygame.movie' - imported by pygame (optional)
missing module named pygame.SRCALPHA - imported by pygame (top-level), pygame.ftfont (top-level)
missing module named Queue - imported by pygame.threads (conditional)
missing module named Py25Queue - imported by pygame.threads (conditional)
missing module named cStringIO - imported by pygame.compat (conditional)`

我无法理解错误是什么

1 个答案:

答案 0 :(得分:0)

Pyinstaller没有每个模块。这意味着pyinstaller仅支持部分模块。 Here是pyinstaller支持的模块的完整列表。