os.path.dirname(__file__) returns empty
Because os.path.abspath = os.path.dirname + os.path.basename does not hold. we rather have Both dirname() and basename() only split the passed filename into components without taking into account the current directory. If you want to also consider the current directory, you have to do so explicitly. To get the dirname of the absolute path, use