py2exe打包问题,急急,请高手指点

tangzhangchun 发布于 2010/08/30 10:27
阅读 2K+
收藏 2

I install the openopt 0.29 and can make through with the test 'nlp1.py'. but when I convert it to EXE with py2exe(py2exe-0.6.9.win32-py2.5), it raises the error:
 我安装了openopt 0.29并且通过了测试"nlp1.py",但是当我用py2exe(py2exe-0.6.9.win32-py2.5)转化为EXE文件时,出现错误:
Traceback (most recent call last):
  File "I:\WORK2010\text\nlp1.py", line 75, in <module>
    isPassed, r, p = test(iprint= 10, plot=0)
  File "I:\WORK2010\text\nlp1.py", line 70, in test
    r = p.solve(solver)
  File "openopt\kernel\baseProblem.pyo", line 222, in solve
  File "openopt\kernel\runProbSolver.pyo", line 62, in runProbSolver
  File "openopt\kernel\nonOptMisc.pyo", line 86, in getSolverFromStringName
  File "openopt\kernel\oologfcn.pyo", line 16, in ooerr
openopt.kernel.oologfcn.OpenOptException: incorrect solver is called, maybe the
solver "scipy_slsqp" is not installed. Also, maybe you have forgotten to use "py
thon setup.py install" after updating OpenOpt from subversion repository

the transforming file related with py2exe is given as follows:

from distutils.core import setup
import py2exe
import sys
import os

import glob
if len(sys.argv) == 1:
    sys.argv.append("py2exe")
    sys.argv.append("-q")

opts = {
        'py2exe': {"compressed": 1, "optimize": 2,
                    "includes": [#"sip", "PyQt4._qt",
                                "numpy", "scipy", "scipy.optimize",
                                #"openopt",
                                #"openopt.kernel",
                                #"openopt.solvers",
                                #"openopt.solvers.scipy_optim","openopt.solvers.BrasilOpt", "openopt.solvers.CoinOr","openopt.solvers.CVXOPT","openopt.solvers.nlopt","openopt.solvers.Standalone","openopt.solvers.UkrOpt","openopt.solvers.scipy_optim.scipy_slsqp_oo",
                                                                ],
                 'excludes': ['_gtkagg', '_tkagg', '_agg2', '_cairo', '_cocoaagg','_fltkagg', '_gtk', '_gtkcairo', ],
                 'dll_excludes': ['libgdk-win32-2.0-0.dll','libgobject-2.0-0.dll'],
                 'dist_dir':'I:\\WORK2010\\text\\dist',

               }
        }

data_files = []

setup(
    # The first three parameters are not required, if at least a
    # 'version' is given, then a versioninfo resource is built from
    # them and added to the executables.
    options = opts,
    data_files=data_files,

    # targets to build
    console = ["nlp1.py"],
    )


加载中
0
y
yigl

你的setup.py文件应该没有错,你的源程序编译的时候没有出错,但是Py2exe的时候会出错,请从以下方面检查:

1、将源程序中的汉字解释全部删掉,这个影响打包

2、变量名称尽量避免重名,例如你的

File "I:\WORK2010\text\nlp1.py", line 70, in test
    r = p.solve(solver)

中p.solve(solver)就会出错,建议采用不同的变量,改为p.sol(solver)或者p.solve(sol)

3、程序重新理一遍

that is all,good luck!

返回顶部
顶部