I'm having issues loading files by thier path over my code which runs over Windows (local test and development) and Linux (CI CD).
While running my code locally in Windows, the file path relative works fine, when my code is running over Linux it turns to a mess and returns an Error: No such file or directory
Is there such a code in Python which is cross platform to solve it ?
My code is like this:
def get_event_json_file_path(fileName):
file_dir = os.path.dirname(os.path.realpath('__file__'))
file_path = os.path.join(file_dir, "events/" + fileName)
return file_path
Is there a code to get the classpath of the folder ?
os.pathand below to platform-independently handle paths, make absolute ones relative, etc.os.path.dirname(os.path.realpath('__file__'))from should be deleted. Such a fundamental lack of understanding...