在Python中使用纸浆时FileNotFoundError
我试图通过皮顿的纸浆来解决线性规划问题。 我已声明问题(通过名称prob),没有任何错误:在Python中使用纸浆时FileNotFoundError,python,python-3.x,anaconda,linear-programming,pulp,Python,Python 3.x,Anaconda,Linear Programming,Pulp,我试图通过皮顿的纸浆来解决线性规划问题。 我已声明问题(通过名称prob),没有任何错误: MAXIMIZE 20*x1 + 30*x2 + 0 SUBJECT TO _C1: x1 + 2 x2 <= 100 _C2: 2 x1 + x2 <= 100 VARIABLES x1 Continuous x2 Continuous 这是我得到的错误 -----------------------------------------------------------------
MAXIMIZE
20*x1 + 30*x2 + 0
SUBJECT TO
_C1: x1 + 2 x2 <= 100
_C2: 2 x1 + x2 <= 100
VARIABLES
x1 Continuous
x2 Continuous
这是我得到的错误
---------------------------------------------------------------------------
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
---------------------------------------------------------------------------
FileNotFoundError回溯(最近一次调用上次)
在里面
---->1问题解决()
求解中的~\Anaconda3\lib\site packages\pulp\pulp.py(self,solver,**kwargs)
1662#计时
1663 self.solutionTime=-clock()
->1664状态=解算器。实际解算器(自身,**kwargs)
1665自我解决时间+=时钟()
1666自我恢复目标(wasNone,dummyVar)
~\Anaconda3\lib\site packages\pulp\solvers.py in actualSolve(self,lp,**kwargs)
1360 def实际解决方案(自身、lp、**kwargs):
1361“解决一个精心设计的lp问题”
->1362返回自求解CBC(lp,**kwargs)
1363
1364 def可用(自身):
求解CBC中的~\Anaconda3\lib\site packages\pulp\solvers.py(self、lp、use\u-mps)
1418 log.debug(self.path+cmds)
1419 cbc=subprocess.Popen((self.path+cmds).split(),stdout=pipe,
->1420标准偏差=管道)
1421如果cbc.wait()!=0:
1422 raise PALLSOLVERROR(“纸浆:尝试执行时出错”+\
初始化中的~\Anaconda3\lib\subprocess.py(self、args、bufsize、executable、stdin、stdout、stderr、preexec\fn、close\fds、shell、cwd、env、universal\u换行符、startupinfo、creationflags、restore\u信号、start\u new\u会话、pass\fds、编码、错误、文本)
773 c2pread,c2pwrite,
774错误读取,错误写入,
-->775恢复信号,启动新会话)
776除:
777#如果孩子启动失败,则进行清理。
执行子进程中的~\Anaconda3\lib\subprocess.py(self、args、executable、preexec\u fn、close\u fds、pass\u fds、cwd、env、startupinfo、creationflags、shell、p2cread、p2cwrite、c2pread、c2pwrite、errread、errwrite、未使用的恢复信号、未使用的启动新会话)
1176环境,
1177 os.fspath(cwd)如果cwd不是None-else-None,
->1178(创业信息)
1179最后:
1180#Child启动。关闭这些管道的父级副本
FileNotFoundError:[WinError 2]系统找不到指定的文件
将记录路径文件。该路径可能不存在,或者程序没有访问该文件的权限(在这种情况下以管理员身份运行)->
FileNotFoundError
-“在Linux和OSX系统上,必须运行测试才能使默认解算器可执行。”-运行sudo pulptest
并再次尝试运行代码?@h4z3遗憾的是,我使用的是Windows Sir-(我不是一个“先生”。@h4z3谢谢。结果并没有达到预期的效果。[WinError 2]系统找不到指定的文件*解算器失败。解算器不可用
等等。知道如何解决此问题吗?尝试以管理员身份执行,但仍然存在问题。在这种情况下如何继续?您是否验证了文件存在?是的,先生。路径和文件都存在。
---------------------------------------------------------------------------
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)