Relative paths in Python - Stack Overflow
stackoverflow.com › questions › 918154May 27, 2009 · dirname = os.path.dirname(__file__) filename = os.path.join(dirname, 'relative/path/to/file/you/want') This will give you the absolute path to the file you're looking for. Note that if you're using setuptools, you should probably use its package resources APIinstead. UPDATE: I'm responding to a comment here so I can paste a code sample.
Relative Path in Python - Delft Stack
www.delftstack.com › howto › pythonAbsolute Path. An absolute path of a file is the complete path from the root directory to that particular file. For example, C:\PythonProjects\Tutorials\Paths\paths.py is the absolute path of paths.py file. We can get the absolute path of the current file as shown below. import os absolutepath = os.path.abspath(__file__) print(absolutepath) Output: