2

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?

tripleee
  • 175,061
  • 34
  • 275
  • 318
dev135
  • 41
  • 4
  • 1
    Does this answer your question? [Python open() gives FileNotFoundError/IOError: Errno 2 No such file or directory](https://stackoverflow.com/questions/12201928/python-open-gives-filenotfounderror-ioerror-errno-2-no-such-file-or-directory) – ImSo3K Nov 10 '21 at 10:45
  • 2
    No. I have tried all the solutions provided in this post, but none of them works for me. Files with short paths work without any issue. This problem happened after updating python to the latest version. – dev135 Nov 10 '21 at 11:36

1 Answers1

2

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.

Community
  • 1
  • 1
dev135
  • 41
  • 4
  • You can mark this answer as the accepted one since it seems to solve your problem. Also keep in mind that there is no need to thank people on stackoverflow. If you are greatful upvote helpful answers / comments or look at some of the questions other have to repay with your own help. – Tim Rasim Nov 10 '21 at 14:57