python 3.x - subprocess : FileNotFound -


could explain error me :

>>> def j(): ...     import subprocess ...     print(subprocess.popen(['command', '-v', 'nmcli'],     stdout=subprocess.pipe, stderr=subprocess.pipe)) ...  >>> j() traceback (most recent call last): file "<stdin>", line 1, in <module> file "<stdin>", line 3, in j file "/usr/lib/python3.4/subprocess.py", line 859, in __init__ restore_signals, start_new_session) file "/usr/lib/python3.4/subprocess.py", line 1457, in _execute_child raise child_exception_type(errno_num, err_msg) filenotfounderror: [errno 2] no such file or directory: 'command' 

i tried string list, not change anything.

thank you,

filenotfounderror: [errno 2] no such file or directory: 'command'

command shell builtin. subprocess.popen not run shell default.

to run shell, pass shell=true:

>>> import subprocess >>> subprocess.check_output('command -v python', shell=true) b'/usr/bin/python\n' 

to find full path executable, use shutil.which() instead:

>>> import shutil >>> shutil.which('python') '/usr/bin/python' 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -