Try the following... ex_name = 'myprogram.exe' if sys.path[0][-len(ex_name):] == ex_name: path = os.path.split(sys.path[0]) else: path = os.path.split(__file__) I don't know if the above works correctly when the script is not a part of an executable, but is imported with zipimport. - Josiah