Search code examples
pythonpython-3.xwindowspython-3.9

an issue in reading files with long paths (>256 characters) after latest python update


After updating python to the latest version (https://www.python.org/downloads/release/python-398/) , an issue related to open files with longer paths is arisen in many of my old and current projects. I am using Windows 11 and I enabled long paths globally in the system. However, after the latest update when I try:

f = open(‘long/path/to/file.txt’)

I receive the follow exception:

FileNotFoundError: [Errno 2] No such file or directory: The_Long_Path_To_The_File

Changing the file name and/or path to make them shorter is not an option. There is no issue when I try to open files with short paths. I got this exception when I try to open files with long path, and I think it happens after updating python to 3.9.8 version. Do you have any suggestions?


Solution

  • I managed to solve this issue by deleting python v3.9.8. I installed python 3.10 instead, and it worked. I think this is a bug in version (3.9.8) [the Microsoft Store version], when it’s used on Windows 11.

    Update: I reported the bug (https://bugs.python.org/issue45777), and I think it will be fixed soon.