0

这是我得到的错误:

Traceback (most recent call last):
    File "C:\Python34\lib\tkinter\__init__.py", line 1487, in __call__
return self.func(*args)
    File "interface.py", line 231, in testsubmit
    File "interface.py", line 202, in optimizations
    File "C:\Python34\lib\site-packages\pulp-1.5.6-py3.4.egg\pulp\pulp.py", line 1619, in solve
status = solver.actaualSolve(self,**kwargs)
AttributeError: 'NoneType' object has no attribute 'actualSolve'

我在 windows 中使用了 python 3.4 的 py2exe。我可以从 python 运行相同的代码,并且在转换 .exe 文件后,它不会运行并给出上述错误消息。从 .py 转换为 .exe 时没有错误。该代码正在使用 Tkinter 制作一个 GUI,并且还有一个利用纸浆的线性优化。有谁知道这是为什么?部分代码:

from tkinter import *
from tkinter.ttk import *
from pulp import *

class Gui(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent)
        self.parent = parent
        self.initUI()
def optimizations(self):
    numberEzroofmtg, lngths, wdths, hghts = self.lengthsEzmtg()        
    prob = pulp.LpProblem('the simple problem', LpMinimize)

    self.indices = ['206_rail','164_rail','124_rail','84_rail']

    self.x = pulp.LpVariable.dict("x_%s", self.indices,lowBound =0, cat = LpInteger)
    # length data
    self.lengths = dict(zip(self.indices, [206, 164, 124, 84]))
    prob += sum([self.x[i]*self.lengths[i] for i in self.indices]) >= lngths
    prob += self.x['124_rail'] <= 1
    prob.solve()

    return int(self.x['164_rail'].value())*2, int(self.x['124_rail'].value())*2
    self.quit()

def testsubmit(self):
    Rails_164, Rails_124 = self.optimizations()

    self.entries['Number of Helio Std. Rail (L=164)'].delete(0,END)
    self.entries['Number of Helio Std. Rail (L=164)'].insert(0, Rails_164 )
4

1 回答 1

1

看起来纸浆模块找不到可用的求解器。据我所知,它使用外部 DLL 和命令来解决问题,而 py2exe 无法知道这一点,因此不包括它们。您需要明确告诉 py2exe 您正在使用这些文件,可能是通过在脚本中使用dist-file关键字。setup.py

于 2014-07-22T05:01:31.167 回答