我PuLP
通过 iPython notebook 和 Python 2.7 在 OS X 上运行。glpk
使用安装brew install homebrew/science/glpk
,PuLP 安装通过pip install pulp
.
但是我在 Python 中遇到了错误:
---------------------------------------------------------------------------
PulpSolverError Traceback (most recent call last)
<ipython-input-15-689fef0dd94f> in <module>()
1 # Solve the problem
----> 2 status = prob.solve(GLPK(msg=0))
3
/Users/x/anaconda/envs/data/lib/python2.7/site-packages/pulp/pulp.pyc in solve(self, solver, **kwargs)
1641 #time it
1642 self.solutionTime = -clock()
-> 1643 status = solver.actualSolve(self, **kwargs)
1644 self.solutionTime += clock()
1645 self.restoreObjective(wasNone, dummyVar)
/Users/x/anaconda/envs/data/lib/python2.7/site-packages/pulp/solvers.pyc in actualSolve(self, lp)
364 stderr = pipe)
365 if rc:
--> 366 raise PulpSolverError("PuLP: Error while trying to execute "+self.path)
367 else:
368 if os.name != 'nt':
PulpSolverError: PuLP: Error while trying to execute glpsol
这是触发此错误的代码:
from pulp import *
#Variables
x = LpVariable('x')
y = LpVariable('y')
# Problem
prob = LpProblem('problem', LpMinimize)
# Constraints
prob += x + y <= 1
prob += x <= 1
prob += -2 + y <= 4
# Objective function to minimize
prob +=
# Solve the problem
status = prob.solve(GLPK(msg=0))
导致错误的原因是什么,如何解决?