简体   繁体   English

linux命令产生Python OSError:[Errno 2]没有这样的文件或目录

[英]linux command produce Python OSError: [Errno 2] No such file or directory

I have a problem... 我有个问题...

import sys
import subprocess
subprocess.call(['traceroute -I www.yahoo.com'])

and I had try 我试过了

import sys
import subprocess    
subprocess.call(['/usr/sbin/traceroute -I www.yahoo.com'])

why I am recieving the following error message: "OSError: [Errno 2] No such file or directory". 为什么我收到以下错误消息:“OSError:[Errno 2]没有这样的文件或目录”。 Can anyone help...thanks! 谁能帮忙......谢谢!

I hate to answer without knowing the much about the underlying reasons, but I've run into this before with subprocess. 我不想在不知道底层原因的情况下回答,但我在使用子进程之前遇到过这种情况。 The call arguments list really wants a list -- I assume it is looking for an executable with spaces in the name, exactly matching what you enter. 调用参数列表确实需要一个列表 - 我假设它正在查找名称中带有空格的可执行文件,与您输入的内容完全匹配。 Try this instead: 试试这个:

import subprocess
subprocess.call(['traceroute', 'www.yahoo.com'])
import sys
import subprocess
subprocess.call('traceroute -I www.yahoo.com',shell=True)

You can simply do this with shell=True option. 您可以使用shell=True选项执行此操作。

暂无
暂无

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

相关问题 Python:OSError:[Errno 2] 没有那个文件或目录:'' - Python: OSError: [Errno 2] No such file or directory: '' Python OSError:[Errno 2]没有这样的文件或目录 - Python OSError: [Errno 2] No such file or directory Python:OSError:[Errno 2]没有这样的文件或目录 - Python : OSError: [Errno 2] No such file or directory Python:“ OSError:[Errno 2]没有这样的文件或目录:”…找到了它的文件? - Python: “OSError: [Errno 2] No such file or directory:”… with the file it found? Python OSError:[Errno 2]没有这样的文件或目录错误 - Python OSError: [Errno 2] No such file or directory ERROR Python多处理池,OSError:Errno 2没有这样的文件或目录 - Python multiprocessing Pool, OSError: Errno 2 No such file or directory OSError: [Errno 2] 没有那个文件/目录 - OSError: [Errno 2] No such file/directory Traceroute的Python脚本和在文件中打印输出显示Linux Mint中的错误(OSError:[Errno 2]没有这样的文件或目录) - Python Script for Traceroute and printing the output in file shows error( OSError: [Errno 2] No such file or directory) in Linux Mint subprocess.Popen:仅在Linux上,“ OSError:[Errno 2]没有这样的文件或目录” - subprocess.Popen: 'OSError: [Errno 2] No such file or directory' only on Linux Python - Windows - Popen(shlex.split(command), shell=False 导致 OSError: [Errno 2] 没有这样的文件或目录 - Python - Windows - Popen(shlex.split(command), shell=False causes OSError: [Errno 2] No such file or directory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM