簡體   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