File operations‎ > ‎File commands‎ > ‎

get module path

To get python script or moduls directory, add os.path commands  inside a script with argument __file__

# to get full path of script location (not working directory)
module_dir = os.path.dirname(os.path.realpath(__file__))
print(module_dir)
/home/user/python/myscripts

# full path including script name
os.path.realpath(__file__)
/home/user/python/myscripts/myscript.py

# get relative path directory
os.path.dirname(__file__)
./python/myscripts