【发布时间】:2011-11-23 02:43:01
【问题描述】:
在我的主脚本中,我们称之为 MyScript.py,我有这样的:
import psyco
psyco.full()
然后我的 setup.py 看起来像这样:
from distutils.core import setup
import py2exe, sys, os, glob
sys.argv.append('py2exe')
import psyco #speed up compilation
psyco.full()
def find_data_files(source,target,patterns):
"""Locates the specified data-files and returns the matches
in a data_files compatible format.
source is the root of the source data tree.
Use '' or '.' for current directory.
target is the root of the target data tree.
Use '' or '.' for the distribution directory.
patterns is a sequence of glob-patterns for the
files you want to copy.
"""
if glob.has_magic(source) or glob.has_magic(target):
raise ValueError("Magic not allowed in src, target")
ret = {}
for pattern in patterns:
pattern = os.path.join(source,pattern)
for filename in glob.glob(pattern):
if os.path.isfile(filename):
targetpath = os.path.join(target,os.path.relpath(filename,source))
path = os.path.dirname(targetpath)
ret.setdefault(path,[]).append(filename)
return sorted(ret.items())
setup(
name="MyScript",
version="1.0",
description="a script that does something",
author="Keelx",
data_files=find_data_files('.','',[
'gfx/*',
'data/*',
]),
options={'py2exe': {'bundle_files': 1,'optimize': 2}},
windows=[{'script': "MyScript.py"}],
zipfile=None,
)
它会创建一个“dist”文件夹,其中包含可执行文件、win9x 可执行文件以及可执行文件旁边的 gfx 和数据文件夹。但是,当我运行它时,它会将我指向一个日志,上面写着:
Traceback(最近一次调用最后一次): 文件“MyScript.py”,第 16 行,在 文件“zipextimporter.pyo”,第 82 行,在 load_module 文件“psyco__init__.pyo”,第 64 行,在 WindowsError: [错误3] 系统找不到指定路径:'C:\Documents and Settings\Keelx\Desktop\MyScriptFolder\dist\MyScript.exe\psyco\_psyco.pyd'
似乎 psyco 模块没有被放入可执行文件中。我一直在寻找,我还没有找到让 py2exe 复制 psyco 的有效解决方案。
请不要按照“不要使用 py2exe”的方式发布解决方案。
在此先感谢能帮助我的人。
【问题讨论】: