【问题标题】:FileNotFoundError: [WinError 2] The system cannot find the file specified but paths are correctFileNotFoundError: [WinError 2] 系统找不到指定的文件但路径正确
【发布时间】:2021-07-13 03:42:07
【问题描述】:

我查看了其他 20 个不断收到此错误的人的帖子,但没有一个人帮助我解决了我的问题。

我正在尝试将文件加载到 TorchNeuralNet 中,以用于人脸验证。

parser = argparse.ArgumentParser()

parser.add_argument('--images', type=str, nargs='+', help="Input Images.")
parser.add_argument('--dlibFacePredictor', type=str, help="Path to dlib's face predictor.",
                    default=os.path.join(dlibModelDir,"landmarks.dat"))
parser.add_argument('--networkModel', type=str, help="Path to Torch network model.",
                    default=os.path.join(openfaceModelDir, "nn4.small2.v1.t7"))
parser.add_argument('--imgDim', type=str, help="Default image dimension.", default=96)
parser.add_argument('--verbose', action=('store_true'))

args = parser.parse_args()

错误发生在这一行。

net = openface.TorchNeuralNet(args.networkModel, args.imgDim)

起初我以为问题出在文件的路径上,但不是我在变量资源管理器中签入,解析器正常保存。

错误完整的错误是:

Exception ignored in: <function TorchNeuralNet.__del__ at 0x00000235C5A80D30>
Traceback (most recent call last):
  File "C:\Users\user\anaconda3\envs\virenv\lib\site-packages\openface\torch_neural_net.py", line 109, in __del__
if self.p.poll() is None:
 AttributeError: 'TorchNeuralNet' object has no attribute 'p'
Traceback (most recent call last):

   File "C:\Users\user\Desktop\Diplomski\main2.py", line 39, in <module>
     net = openface.TorchNeuralNet(args.networkModel, args.imgDim)

   File "C:\Users\user\anaconda3\envs\virenv\lib\site- 
   packages\openface\torch_neural_net.py", line 
     84, in __init__
     self.p = Popen(self.cmd, stdin=PIPE, stdout=PIPE, bufsize=0, 
universal_newlines=True)

   File "C:\Users\user\anaconda3\envs\virenv\lib\site- 
        packages\spyder_kernels\customize\spydercustomize.py", line 108, in 
__init__
     super(SubprocessPopen, self).__init__(*args, **kwargs)

   File "C:\Users\user\anaconda3\envs\virenv\lib\subprocess.py", line 951, in __init__
     self._execute_child(args, executable, preexec_fn, close_fds,

   File "C:\Users\user\anaconda3\envs\virenv\lib\subprocess.py", line 1420, in _execute_child
     hp, ht, pid, tid = _winapi.CreateProcess(executable, args,

 FileNotFoundError: [WinError 2] The system cannot find the file specified

这里是 openface 的文档:https://openface-api.readthedocs.io/en/latest/openface.html

【问题讨论】:

  • 考虑到默认是96,imgDim不应该是int,而不是str
  • 这似乎与argparse 完全无关——您应该能够提取argparse 的路径/命名空间并静态重现问题。所以,请edit您的问题提供正确的minimal reproducible example。请注意,错误消息表明路径可执行文件未找到或不可执行,而不是缺少某些保存文件。
  • source coderelated questions 建议torch 通过lua 脚本运行,th lua 解释器/包装器。您必须检查这是否可用。
  • 执行print(args) 以查看解析器产生了什么。如果值看起来正确,那么这不是argparse 问题。尝试了解错误发生在代码中的哪个位置。这比在世界上寻找与你的错误完全一致的人更有效率。

标签: python path argparse


【解决方案1】:

OpenFace 的解析器在 Windows 上也不能很好地工作。尝试了一些 Docker 的东西,但没有用。过渡到 dlib 和 opencv,我正在取得进展。

【讨论】:

    猜你喜欢
    • 2018-12-03
    • 2020-01-29
    • 1970-01-01
    • 1970-01-01
    • 2022-01-23
    • 2021-10-13
    • 2021-08-20
    • 2022-12-11
    • 2018-05-21
    相关资源
    最近更新 更多