Rereading my sent answer i wondered, what the variable s was used for besides that "find" and found nothing. Without it also the layout is better: if os.environ['PATH'].find(gtkBinDir) == -1: os.putenv("PATH", os.getenv("PATH")+ os.pathsep + gtkBinDir)