How to fix IsADirectoryError: [Errno 21] Is a directory: 'dirname' in Python | DevErrors