I am using python 3.6.9 on my ubuntu 18.04LTS install and trying to use the subprocess library to call a compiled C++ function. The function takes no arguments so I would figure this should work:
subprocess.Popen(["ais"], stdout=subprocess.PIPE)
but doing so returns
>>> Popen(["ais"])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.6/subprocess.py", line 729, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.6/subprocess.py", line 1364, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ais': 'ais'
This is a little confusing to me given that calling os.listdir() from the same directory returns:
>>> print(os.listdir())
['COM6 ARPA_A.txt', 'dataStream.py', 'arpa.cpp', 'arpa', 'COM7 AIS.txt', 'ais.cpp', 'ais']
cwd(or.) is in the currentPATHyou wouldn't have been able to type outaisin the shell and have your program execute, you would have had to type out./ais. So do the same thing and runPopen(["./ais"])instead. This of course assumesaishas the executable bit set.