繁体   English   中英

在py2exe中使用psyco?

[英]Using psyco with py2exe?

在我的主脚本中,将其命名为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和data文件夹。 但是,当我运行它时,它指向一条日志,内容为:

追溯(最近一次通话最近):Windows中的文件“ zipextimporter.pyo”的第16行,load_module的第82行,Windows中的文件“ psyco__init __。pyo”的第64行,错误:[错误3]系统找不到指定的路径:“ C:\\ Documents and Settings \\ Keelx \\ Desktop \\ MyScriptFolder \\ dist \\ MyScript.exe \\ psyco \\ _psyco.pyd”

似乎psyco模块未放入可执行文件中。 我一直在搜索,但是还没有找到一种有效的解决方案来使py2exe复制psyco。

并且请不要按照“请勿使用py2exe”的方式发布解决方案。

预先感谢您,任何可以在这里帮助我的人。

寻找py2exe错误对我来说似乎是一门艺术。 也就是说,我至少会提供一些尝试。 我py2exe创建了一个启用了psyco的python脚本,并将其扔到设置的包括部分中。 那就是您的设置和我的旧设置之间看起来唯一不同的部分。

options = {'py2exe': {'packages': [ 'IPython'],
                      'includes': ["psyco"],
                     }
          }

我也从来没有启用优化。 它总是引起随机错误。 根据我的经验,最好不要再选择那个了。 我认为正是matplotlib导致了这些错误。

希望这会有所帮助,干杯,

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM