首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在py2exe中使用精神病学?

在py2exe中使用精神病学?
EN

Stack Overflow用户
提问于 2011-11-23 02:43:01
回答 1查看 253关注 0票数 1

在我的主脚本中,让我们调用这个MyScript.py,我这样做:

代码语言:javascript
复制
import psyco
psyco.full()

然后我的setup.py看起来是这样的:

代码语言:javascript
复制
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和数据文件夹。但是,当我运行它时,它将指向一个日志,该日志如下:

Settings\Keelx\Desktop\MyScriptFolder\dist\MyScript.exe\psyco\_psyco.pyd‘跟踪(最近一次调用):文件"MyScript.py",第16行,文件"zipextimporter.pyo“中的第82行,load_module文件"psyco__init__.pyo”中的第64行,在WindowsError: Error 3中,系统找不到指定的路径:'C:\Documents和zipextimporter.pyo

似乎没有将精神病学模块放入可执行文件中。我一直在搜索,但我还没有找到一个可行的解决方案来让py2exe复制精神病学。

请不要发布类似于“不要使用py2exe”的解决方案。

谢谢你能帮我的忙。

EN

回答 1

Stack Overflow用户

发布于 2011-11-23 04:16:14

寻找py2exe错误对我来说似乎是一门艺术。话虽如此,我至少会提出一些尝试。我编写了一个启用了精神病学的python脚本,并将它抛到安装的includes部分中。这是唯一的部分,看上去不同的设置和我的旧的。

代码语言:javascript
复制
options = {'py2exe': {'packages': [ 'IPython'],
                      'includes': ["psyco"],
                     }
          }

而且,我从来没有能够启用优化。它总是会造成随机错误。根据我的经验最好别再提那件事了。我认为是matplotlib造成了这些错误。

希望这能帮上忙,干杯

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8236718

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档