For future searchers, if none of the above worked, for me, python was trying to open a folder as a file.
Check at the location where you try to open the file, if you have a folder with exactly the same name as the file you try to open (the file extension is part of the file name).