首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Python正在运行,但exe未运行。AttributeError

Python正在运行,但exe未运行。AttributeError
EN

Stack Overflow用户
提问于 2014-07-22 08:16:02
回答 1查看 590关注 0票数 0

这是我得到的错误:

代码语言:javascript
运行
复制
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中使用了python3.4的py2exe。我可以从python运行相同的代码,在转换.exe文件后,它没有运行,并给出了上面的错误消息。从.py转换为.exe时没有错误。代码是使用Tkinter制作GUI,也有一个利用纸浆的线性优化。有人知道为什么会这样吗?代码的一部分:

代码语言:javascript
运行
复制
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 )
EN

回答 1

Stack Overflow用户

发布于 2014-07-22 13:01:31

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

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

https://stackoverflow.com/questions/24876923

复制
相关文章

相似问题

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