def interpreter_from_shebang(script):
    """Tries to guess the interpreter to use from the shebang of the
    script. Returns None if none is found."""
    with open(script) as f:
        line = next(f)
        if line.startswith('#!'):
            if 'env' in line:
                return line.strip().split('env ')[1]
            else:
                return line.strip().split('/')[-1]
    return None