Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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". Can anyone help...thanks!

like image 570
dong Avatar asked Dec 29 '25 17:12

dong


1 Answers

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'])
like image 185
5 revs, 4 users 78% Avatar answered Dec 31 '25 06:12

5 revs, 4 users 78%



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!