简体   繁体   English

在 Python 中使用 PuLP 时出现 FileNotFoundError

[英]FileNotFoundError while using PuLP in Python

I am trying to solve Linear Programing Problem through PuLP in pyhthon.我正在尝试通过 pyhthon 中的 PuLP 解决线性规划问题。 I have declared the problem (by name prob) without any error:我已经声明了问题(按名称 prob)没有任何错误:

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
   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该路径可能不存在或程序无权访问该文件(在这种情况下以管理员身份运行)-> FileNotFoundError

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM