从使用PuLP的Python脚本创建单个可执行.exe

时间:2014-06-17 03:16:27

标签: python-2.7 py2exe cx-freeze pulp

我一直在努力解决这个问题。我用py2exe和cx_freeze包装了一切。我正在使用32位机器,一切正常,界面打开,我知道整个puLP包的所有内容都没有被正确复制到包中。我知道这是因为解算器不起作用。在py2exe和cx_freeze创建的包中的两个库拉链中,只包含.pyc文件,其中PuLP具有cbc.exe和其他使解算器工作的文件类型。

这有什么工作吗?我已经尝试将实际的PuLP包复制到library.zip以及dist文件夹中,但是没有用。

以下是我用于py2exe的设置:     导入系统     来自cx_Freeze导入设置,可执行文件

# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": ["pulp"], 
                    "icon": "icon.ico",
                    "include_files": ["icon.ico","cbc.exe","cbc-32","cbc-64","cbc-osx-64","CoinMP.dll"]}

# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
if sys.platform == "win32":
    base = "Win32GUI"

setup(  name = "my_app",
        version = "0.1",
        options = {"build_exe": build_exe_options},
        executables = [Executable("my_app.py", base=base)])

我收到以下错误:

Exception in Tkinter callback
Traceback (most recent call last):
  File "Tkinter.pyc", line 1470, in __call__
  File "my_app.py", line 796, in <lambda>
  File "my_app.py", line 467, in branchAndBound
  File "pulp\pulp.pyc", line 1619, in solve
AttributeError: 'NoneType' object has no attribute 'actualSolve'

修改 我试图改变cbc.exe和CoinMP.dll的路径,但这并没有真正起作用。我可能错过了一些东西。

我在PuLP包中修改了以下solvers.py:

try:
    coinMP_path = config.get("locations", "CoinMPPath").split(', ')
except configparser.Error:
    coinMP_path = ['/Users/al/Desktop/my_app/build/exe.win32-2.7']

try:
    cbc_path = config.get("locations", "CbcPath")
except configparser.Error:
    cbc_path = '/Users/al/Desktop/my_app/build/exe.win32-2.7'

try:
    pulp_cbc_path = config.get("locations", "PulpCbcPath")
except configparser.Error:
    pulp_cbc_path = '/Users/al/Desktop/my_app/build/exe.win32-2.7'

我错过了什么或做错了什么?

0 个答案:

没有答案