Search code examples
pythonwindowssyssys.path

When I append a path, python gives an error


I tried to add a directory path to sys.path, but it gives me an error:

import sys
sys.path.append("C:\Users\tamer\Desktop\code\python\modules")
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

Solution

  • This should do it:

    sys.path.append("C:\\Users\\tamer\\Desktop\\code\\python\\modules")