Home:ALL Converter>Invoking program compiled using linux subsytem through python on windows

Invoking program compiled using linux subsytem through python on windows

Ask Time:2018-05-03T06:10:28         Author:user308827

Json Formatter

I have a program I compiled in the Linux subsystem introduced in Windows 10. How can I use the python subprocess command to invoke it? By default the subprocess command seems to use the windows shell and not the linux subsytem

Here is a sample program (remember that while I am running it through a windows python anaconda interpretor), I do have linux subsytem installed

import subprocess
subprocess.Popen('ls', shell=False)

results in error:

Traceback (most recent call last):
  File "C:\Users\rt\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2963, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-3-cf9f6642ea11>", line 1, in <module>
    subprocess.Popen('ls', shell=False)
  File "C:\Users\rt\Anaconda3\lib\subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "C:\Users\rt\Anaconda3\lib\subprocess.py", line 997, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

Author:user308827,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/50144269/invoking-program-compiled-using-linux-subsytem-through-python-on-windows
yy