简体   繁体   English

Python Popen找不到指定的文件

[英]Python Popen Cannot Find the File Specified

I have the following code 我有以下代码

pathToFile = "R:\T2 Output\12345--01--Some File 1--ABCD.mp4"
process = subprocess.Popen(['ffprobe.exe', '-show_streams', '"'+pathToFile+'"'],
    shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

I get the error: 我得到错误:

[Error 2] The system cannot find the file specified

What I have tried: 我试过的

  • Changing shell=True to shell=False 将shell = True更改为shell = False
  • Combining the command into a single string instead of using a list (I even print it to screen, and I can copy and paste into a command prompt where the file runs and gives the expected output (no error) 将命令组合成一个字符串而不是使用列表(我什至将其打印到屏幕上,而且我可以将其复制并粘贴到命令提示符下,文件在其中运行并提供预期的输出(无错误)
  • I made sure that ffprobe.exe is located in the PATH and can be executed from the command line without specifying a directory 我确保ffprobe.exe位于PATH中并且可以在不指定目录的情况下从命令行执行

Things of note: 注意事项:

  • The file is located on a mapped network drive (R) 该文件位于映射的网络驱动器(R)上
  • The file has spaces in the filename, this is why I surrounded it by quotes. 该文件名中有空格,这就是为什么我用引号将其引起来。

I'm sure I'm missing something simple. 我确定我缺少一些简单的东西。 Can anyone point me in the right direction? 谁能指出我正确的方向? I've done quite a lot of searching on this site and others and trying suggestions. 我已经在该网站和其他网站上进行了大量搜索,并尝试提出建议。

\\符号在python中算作转义字符,使用r可以将其关闭:

pathToFile = r"R:\T2 Output\12345--01--Some File 1--ABCD.mp4"

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

相关问题 Python:系统找不到使用subprocess.Popen指定的文件 - Python: the system cannot find the file specified using subprocess.Popen 在python中调用subprocess.Popen时“系统找不到指定的文件” - "The system cannot find the file specified" when invoking subprocess.Popen in python python ghostscript Popen 找不到文件 - python ghostscript Popen cannot find file 使用popen显示WindowsError:[错误2]系统找不到指定的文件 - using popen shows WindowsError: [Error 2] The system cannot find the file specified 从python中的Popen内部执行时,rsync无法找到文件 - rsync cannot find file when executed from within Popen in python WindowsError:[错误2]系统找不到pexpect.popen_spawn.PopenSpawn中指定的文件 - WindowsError: [Error 2] The system cannot find the file specified in pexpect.popen_spawn.PopenSpawn 系统找不到使用子进程Popen指定的文件,只能在具有简单bat文件的桌面上工作 - The system cannot find the file specified using subprocess Popen and only works on desktop with simple bat files WinError 2 系统找不到指定的文件(Python) - WinError 2 The system cannot find the file specified (Python) tesseract python系统找不到指定的文件 - tesseract python The system cannot find the file specified 系统找不到指定的文件 Python - The system cannot find the file specified Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM