Skip to content Skip to sidebar Skip to footer

Valueerror: Invalid \x Escape:

ValueError: invalid \x escape: File 'SConstruct', line 49: execfile('hosts.cfg') I'm completely stumped with this one guys... If I print right before line 49, I can see the

Solution 1:

Even on Windows, forward slashes should work for directory names, so you could standardize on those:

"libpath":[".","../xlib","../tools","../info"],

Or use raw strings, as @Adam Rosenfield already said in a comment:

"libpath" : [r".", r"..\xlib", r"..\tools", r"..\info"],

I think both of the above solutions are better than doubling all the backslashes, and loads better than just doubling backslashes for directory names that start with 'x'.

Solution 2:

"libpath" : [".", "..\xlib", "..\tools", "..\info"],

This was the problematic line inside hosts.cfg, don't know why Python kept complaining about the execfile line instead of the one inside the file I was calling.

I changed to:

\\xlib and it's working now.

Post a Comment for "Valueerror: Invalid \x Escape:"