【问题标题】:simplegui based pygame to exe file, numpy-atlas.dll error基于 simplegui 的 pygame 到 exe 文件,numpy-atlas.dll 错误
【发布时间】:2017-09-23 15:58:23
【问题描述】:

我有一个使用 codeskulptor simplegui 工具开发的工作游戏。我通过 SimpleGUICS2Pygame 将其转换为 pygame。我尝试将其转换为exe,它运行此错误: [Errno 2] 没有这样的文件或目录:'numpy-atlas.dll'

我查看了这个帖子:Py2Exe, [Errno 2] No such file or directory: 'numpy-atlas.dll'

我尝试将numpy-atlas.dll复制到代码文件目录,它工作,但是当我尝试运行exe文件时,命令行只是弹出并消失。

我找到了最后一个可行的答案,但我不知道如何/在哪里运行这样的代码:

    from distutils.core import setup
    import py2exe

    import numpy
    import os
    import sys

    # add any numpy directory containing a dll file to sys.path

    def numpy_dll_paths_fix():
        paths = set()
        np_path = numpy.__path__[0]
        for dirpath, _, filenames in os.walk(np_path):
            for item in filenames:
                if item.endswith('.dll'):
                    paths.add(dirpath)

        sys.path.append(*list(paths))

    numpy_dll_paths_fix()
    setup(...)

我用pyinstaller重新编译了,成功了,但是没有功能,下面是spec文件的样子:

# -*- mode: python -*-

block_cipher = None


a = Analysis(['balling.py'],
             pathex=['C:\\Users\\SamsunG\\Desktop\\Python 2017\\convert'],
             binaries=[],
             datas=[],
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          exclude_binaries=True,
          name='balling',
          debug=False,
          strip=False,
          upx=True,
          console=True )
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=False,
               upx=True,
               name='balling')

【问题讨论】:

  • 也许使用 cx_Freeze 甚至更好 - Pyinstaller?
  • 我使用了 pyinstaller,一切正常,但是当我试图让我的 exe 游戏在分发目录中运行时,windows 要求关闭命令提示符。我的游戏没有外部路径,它是乒乓球。请在上面查找已创建捆绑包的规范文件。

标签: python numpy dll pygame


【解决方案1】:

我从未使用过,也永远不会使用 py2exe 和 py2app。我总是使用 cx_Freeze 然后删除它并安装 Pyinstaller 因为它提供run bat or shell -> delete build dir -> go to dist dir -> run that exe 系统。要使用它:

  1. 安装 Pyinstaller:在你的 shell 中输入 pip install pyinstaller。在 Windows 上,如果为所有用户安装了 Python,请不要忘记以管理员权限运行它。

  2. cd 与您的 Python 文件一起进入目录。

  3. 确保您已剪切粘贴“构建”文件夹(如果存在)。输入pyinstaller <python_file_name> --noconsole -F--noconsole 用于删除 exe 中的控制台窗口,-F 用于单文件编译。这就是我更喜欢 Pyinstaller 的原因。

  4. 稍等片刻。然后获取您的 .exe!

  5. 删除出现的“build”文件夹。

Pyinstaller 是跨平台的(但 Pyinstaller for Windows 只能编译用于 Windows,Pyinstaller for Linux 只能编译用于 Linux,Pyinstaller for MacOS 只能编译用于 MacOS 等)。


console 设置为 False 或在 EXE 游戏或 GUI 应用程序时编译时使用 --noconsole。

【讨论】:

    猜你喜欢
    • 2020-12-08
    • 1970-01-01
    • 2019-02-25
    • 2018-12-06
    • 2016-04-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多