The issue you’re dealing with is that \ is the “escape character”, used for things that are hard to type like \n (a newline) or \t (a tab).
If you print(filepath) you’ll see that it doesn’t match the path you wanted.
One option is to use a raw string r"G:\My Drive..." which doesn’t have escape characters. Another option is to double up on the \ to get the string you actually want: "G:\\My Drive" will print as G:\My Drive
Python disagrees, because it sees a different string. (It would be the same story in most programming languages in common use today; Python did not invent this system, but inherited it from C, with some modifications.) The backslashes (\) have a special interpretation, in combination with the following characters. Usually, you would get an error from this, because most people try to open something that’s in their Users folder, and the \U will be invalid when it isn’t followed by 8 hex digits. But as it happens, the \d and \i in your path string mean what they look like; \b means a backspace character, and \t means a tab.
Starting in Python 3.12, you get a SyntaxWarning for sequences like \d that don’t have a special meaning. Before (since 3.6), you would get a DeprecationWarning, but you normally don’t see these without explicitly opting in to them. In some future Python version (not yet decided AFAIK) they will cause an actual SyntaxError.
Just thought I’d follow up with my usual clarification: these
alternatives are just expressions for obtaining the filename string
you want.
You want a Python string containing:
G:\whatever...
The Python expression using a “raw string”:
r'G:\whatever...'
and the Python expression using a plain old quoted string:
"G:\\whatever"
with the doubled backslashes are just 2 different expressions for your
intended string value. They just make a str at the end.
Just want to clarify that there’s no such thing as a “raw string” type
of object; you just get a str. They’re just different ways of writing
that, like 5 and (2+3) are different ways of obtaining the int
with value 5.
We tend to prefer the “raw string” type of expression when we’re dealing
with string values which have backslashes in them, such as Windows paths
and regular expressions.