【发布时间】: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 要求关闭命令提示符。我的游戏没有外部路径,它是乒乓球。请在上面查找已创建捆绑包的规范文件。