I have a problem when programming in Python running under Windows. I need to work with file paths, that are longer than 256 or whatsathelimit characters. Now, I\'ve read ba
Well it seems that, as always, I've found the answer to what's been bugging me for a week twenty minutes after I seriously ask somebody about it.
So I've found that I need to make sure two things are done correctly:
/*.*
to it, which is a forward slash, which is bad.Hope at least someone will find this useful.
py 3.8.2
# Fix long path access:
import ntpath
ntpath.realpath = ntpath.abspath
# Fix long path access.
In my case, this solved the problem of running a script from a long path. (https://developers.google.com/drive/api/v3/quickstart/python) But this is not a universal fix. It looks like the ntpath.realpath implementation has problems. This code replaced it with a dummy.
Let me just simplify this for anyone looking for a straight answer:
u
like u'C:\\path\\to\\file'
\\\\?\\
(which is escaped into \\?\
) like u'\\\\?\\C:\\path\\to\\file'
/
--> \\