繁体   English   中英

py2exe 的可执行文件停止运行

[英]Executable from py2exe stops running

我正在尝试使用 py2exe 从 python 脚本创建 a.exe。 经过一些令人厌烦的研究,我能够运行functional.exe。 但是,我不得不在 my.py 中添加几行,包括一个新的导入。

我的旧进口是:

import numpy as np
import pandas as pd
import os
from scipy import signal
import pywt

我的旧 setup.py 是:

from setuptools import setup
from distutils.core import setup
import py2exe

excludes = []
includes = ["scipy.signal","scipy._lib.messagestream","scipy.spatial.transform._rotation_groups",
            "scipy.special.cython_special","pywt._extensions._cwt"]

opts = {
    "py2exe": {
        "includes":includes,
        "excludes":excludes
    }
}

setup(console=['Shweep.py'], options=opts)

我刚刚添加了我可以从其他相关问题中找到的任何内容,最终它奏效了。

我的问题是新脚本。 我有一些新的进口:

import numpy as np
import pandas as pd
import os
from scipy import signal
from scipy.interpolate import interp1d
import pywt
import math

并且我的 setup.py 运行,并带有有关缺少模块的警告(第一次也有这些,尽管我不确定它们是否相同)。 但是,当我尝试使用 cmd 运行 .exe 时,程序在几秒钟后停止运行,显示即时调试消息,告诉我使用 Visual Studio 进行调试。 当我尝试使用 Visual Studio 在另一台 PC 上运行 same.exe 时,甚至没有显示该消息。

对不起,如果这很简单,我是 py2exe 的初学者

编辑:我试图隔离部分代码以找出导致错误的原因。 似乎与这两个功能有关:

def filter_oximetry(x, t):
    """
    
    Filters a pulse oximetry signal for usage in the find_oximetry_events() function. 
    
    The signal is filtered through a 500th order FIR linear phase lowpass filter with a
    0,1 Hz cutoff frequency. All the values greater than the mean + 9 are replaced by 
    mean - 20 and those bellow mean - 9 are replaced with mean + 20 

    Parameters
    ----------
    x : List or numpy array.
        Oximetry signal.
    t : List or numpy array.
        Signal time.

    Returns
    -------
    y : List or numpy array.
        Filtered signal values.

    """
    
    # Calculating the sampling frequency
    fs = 1/(t[1] - t[0])
    
    # Lowpass linear phase FIR filter, designed through REMEZ.
    # 1500th order, with 0.1 Hz cutoff frequency and passband 
    # gain of 1.
    coef = signal.remez(numtaps = 500, bands = [0, 0.1, 0.2, fs/2], desired = [1, 0], Hz = fs, type = "bandpass")
    
    # Steady state initial conditions    
    zi = signal.lfilter_zi(coef, 1) 
    
    # Filtering the signal
    y, _ = signal.lfilter(coef, 1, x, zi = zi)
    
    # Compensating for a gain lower than 1 in the passband
    y += 6
    
    #Getting rid of spikes
    mean = y.mean()
    for n in range(1, len(y) - 1):
      if (y[n] >= mean + 9) or (y[n] <= mean - 9):
          
        # Interpolation
        y[n] = y[n - 1] - (y[n - 1] - y[n + 1] / 2) 
        
        # If it is still outside the limits...
        if (y[n] >= mean + 9): 
          y[n] = mean - 20
        
        # If it is still outside the limits...
        if (y[n] <= mean - 9): 
          y[n] = mean + 20
    
    return y

def filter_flow(x, flow_t):
    """
    
    Filters an oronasal thermistor signal for usage in the find_flow_events() function. 
    
    The signal is filtered through a 249th order FIR linear phase lowpass filter with a
    1 Hz cutoff frequency.

    Parameters
    ----------
    x : List or numpy array.
        Oximetry signal.
    flow_t : List or numpy array.
        Signal time.

    Returns
    -------
    flow_y : List or numpy array.
        Filtered signal values.

    """

    # Calculating the sampling frequency
    fs = 1/(flow_t[1] - flow_t[0])
    
    # Lowpass linear phase FIR filter, designed through REMEZ.
    # 1500th order, with 0.9 Hz cutoff frequency and passband 
    # gain of 1.
    coef = signal.remez(249, [0, 1, 1.5, fs/2], [1, 0], Hz = fs, type = "bandpass")


    # Steady state initial conditions
    zi = signal.lfilter_zi(coef, 1) 
    
    # Filtering the signal
    flow_y, _ = signal.lfilter(coef, 1, x, zi = zi) 
    
    return flow_y

我仍然不知道为什么它没有输出任何错误消息。 此外,如果我使用 spyder,它运行良好,但在使用可执行文件时则不行

要了解您的问题,您可以查看此帖子:

这里

您的解决方案:

我测试了你的脚本并修改了你的 setup.py 并且当我排除几个模块时它的功能:

from setuptools import setup
from distutils.core import setup
import py2exe

setup(options = {
    "py2exe":
        {   
            "excludes": ["_pytest","qtpy"], 
        }
    },
      console=['Shweep.py'])

我排除了这个模块,因为它们会产生一些问题。

暂无
暂无

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

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