The following script demonstrates a method that should work for you. I believe it is entirely cross-platform. #! /usr/bin/python import sys import os print os.path.abspath(os.path.dirname(sys.argv[0]))