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

<pre><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('&gt; ') #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()
</code></pre>

<p>And now when I'm typing a "mkdir folder" command it returns error: <code>[Errno 2] No such file or directory</code>. 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</p>

<p>Copy-paste from comments in my link (thanks for <a href="http://stackoverflow.com/users/3009212/ari-gold">Ari Gold</a>)</p>

<p>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)</p>

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

<p>For the second problem, the <code>os</code> 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.</p>

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

python python-3.x