Python: [Errno 2] No such file or directory - weird issue
Question: I'm learning with a tutorial [Create your own shell in
Python](https://hackercollider.com/articles/2016/07/05/create-your-own-shell-
in-python-part-1/) and I have some weird issue. I wrote following code:

    
    
    import sys
    import shlex
    import os
    
    SHELL_STATUS_RUN = 1
    SHELL_STATUS_STOP = 0
    
    def shell_loop():
        status = SHELL_STATUS_RUN
    
        while status == SHELL_STATUS_RUN:
            sys.stdout.write('> ') #display a command prompt
            sys.stdout.flush()
            cmd = sys.stdin.readline()  #read command input
            cmd_tokens = tokenize(cmd) #tokenize the command input
            status = execute(cmd_tokens) #execute the command and retrieve new status
    
    def main():
        shell_loop()
    
    def tokenize(string):
        return shlex.split(string)
    
    def execute(cmd_tokens): #execute command
        os.execvp(cmd_tokens[0], cmd_tokens) #return status indicating to wait for the next command in shell_loop
        return SHELL_STATUS_RUN
    
    
    if __name__ == "__main__":
        main()
    

And now when I'm typing a "mkdir folder" command it returns error: `[Errno 2]
No such file or directory`. BUT if I write previously "help" command which
works correctly (displays me all available commands), command mkdir works
correctly and it creating a folder. Please, guide me what's wrong with my
code? I'm writing in Notepad++ on Windows 8.1 64x


Answer: Copy-paste from comments in my link (thanks for [Ari
Gold](http://stackoverflow.com/users/3009212/ari-gold))

Hi tyh, it seems like you tried it on Windows. (I forgot to note that it works
on Linux and Mac or Unix-like emulator like Cygwin only)

For the first problem, it seems like it cannot find `mkdir` command on your
system environment. You might find the directory that the `mkdir` binary
resides in and use execvpe() to explicitly specify environment instead

For the second problem, the `os` module on Windows has no fork() function.
However, I suggest you to use Cygwin on Windows to emulate Unix like
environment and two problems above should be gone.

In Windows 10, there is Linux-Bash, which might work, but I never try.

