0

I am trying to solve Linear Programing Problem through PuLP in pyhthon. I have declared the problem (by name prob) without any error:

MAXIMIZE
20*x1 + 30*x2 + 0
SUBJECT TO
_C1: x1 + 2 x2 <= 100

_C2: 2 x1 + x2 <= 100

VARIABLES
x1 Continuous
x2 Continuous 

But now when I try to solve it, it is giving me an error

Here is what I typed:

prob.solve()

And here is the error I am getting

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-7-613465fcbb4d> in <module>
----> 1 prob.solve()

~\Anaconda3\lib\site-packages\pulp\pulp.py in solve(self, solver, **kwargs)
   1662         #time it
   1663         self.solutionTime = -clock()
-> 1664         status = solver.actualSolve(self, **kwargs)
   1665         self.solutionTime += clock()
   1666         self.restoreObjective(wasNone, dummyVar)

~\Anaconda3\lib\site-packages\pulp\solvers.py in actualSolve(self, lp, **kwargs)
   1360     def actualSolve(self, lp, **kwargs):
   1361         """Solve a well formulated lp problem"""
-> 1362         return self.solve_CBC(lp, **kwargs)
   1363 
   1364     def available(self):

~\Anaconda3\lib\site-packages\pulp\solvers.py in solve_CBC(self, lp, use_mps)
   1418         log.debug(self.path + cmds)
   1419         cbc = subprocess.Popen((self.path + cmds).split(), stdout = pipe,
-> 1420                              stderr = pipe)
   1421         if cbc.wait() != 0:
   1422             raise PulpSolverError("Pulp: Error while trying to execute " +  \

~\Anaconda3\lib\subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors, text)
    773                                 c2pread, c2pwrite,
    774                                 errread, errwrite,
--> 775                                 restore_signals, start_new_session)
    776         except:
    777             # Cleanup if the child failed starting.

~\Anaconda3\lib\subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session)
   1176                                          env,
   1177                                          os.fspath(cwd) if cwd is not None else None,
-> 1178                                          startupinfo)
   1179             finally:
   1180                 # Child is launched. Close the parent's copy of those pipe

FileNotFoundError: [WinError 2] The system cannot find the file specified
8
  • pypi.org/project/PuLP - "On Linux and OSX systems the tests must be run to make the default solver executable." - run sudo pulptest and try running your code again? Commented Mar 10, 2020 at 10:26
  • @h4z3 Sadly I use Windows Sir. :-( Commented Mar 10, 2020 at 11:13
  • I'm not a "sir". Commented Mar 10, 2020 at 11:32
  • coin-or.github.io/pulp/main/… Commented Mar 10, 2020 at 11:35
  • @h4z3 Thank you. The result isn't coming as intended. [WinError 2] The system cannot find the file specified * Solver <class 'pulp.solvers.PULP_CBC_CMD'> failed. Solver <class 'pulp.solvers.CPLEX_DLL'> unavailable And so on. Any idea how to solve this? Commented Mar 10, 2020 at 11:39

1 Answer 1

0
   1418         log.debug(self.path + cmds)
   1419         cbc = subprocess.Popen((self.path + cmds).split(), stdout = pipe,
-> 1420                              stderr = pipe)

The path file is logged. That path probably doesn't exist or the program does not have permission to access the file (run as admin in that case) -> FileNotFoundError

Sign up to request clarification or add additional context in comments.

3 Comments

Tried doing as Admin but still problem persisting. How to proceed in that case?
Have you verified the file exists?
Yes sir. Path and file both exist.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.