Exit codes in Python

You’re looking for calls to sys.exit() in the script. The argument to that method is returned to the environment as the exit code. It’s fairly likely that the script is never calling the exit method, and that 0 is the default exit code.

Removing pip’s cache?

If using pip 6.0 or newer, try adding the –no-cache-dir option (source). If using pip older than pip 6.0, upgrade it with pip install -U pip.

List files ONLY in the current directory

Just use os.listdir and os.path.isfile instead of os.walk. Example: But be careful while applying this to other directory, like which would not work because f is not a full path but relative to the current dir. Therefore, for filtering on another directory, do os.path.isfile(os.path.join(somedir, f)) (Thanks Causality for the hint)