This is reference to video 17 from the “Python Standard Library” section of Mosh’s Complete Python Mastery. The video is entitled “Running External Programs”…

I can’t get any to run, whether or not they are just commands for the command line, or .py files, or even .txt files. The code provided in Mosh’s video is…

import subprocess
result =[“ls”])

When run with the terminal in Visual Studio, this results in an error of “FileNotFoundError: [WinError 2] The system cannot find the file specified”. This true regardless of what command I run. When I run a program, like file, I instead get the error “OSError: [WinError 193] %1 is not a valid Win32 application”. I’ve read this could perhaps come from a mismatch in VS version and OS (64 vs 32 bit), but this is not the case for me. I’ve also read this can come from downloading multiple instances of python. If this can result from downloading both Visual Studip and PyCharm, this might be the case? But I didn’t think downloading two development environments was the same as downloading two distinct versions of python itself. Thanks in advance

I assume you are running windows, based on the information you provided. At the very beginning of the video, he makes note that the “ls” command is to show what is in the directory for macintosh products, for windows the command would be “dir”. For that command to work, you type it directly into your terminal, just as it shows within the quotes.

For the program side of what you are trying to do you could do something like this:

import subprocess

result =[“echo”, “Hello, World!”], shell=True)

My understanding of your issue can be found at python - Error while trying to run command with subprocess - Stack Overflow

Giving that a quick read will probably help a lot better than I can try to relay the information. If you still have questions post them here and I will check back later to see if I can explain better.