0

when I run python code with some comments on top of it I get syntax error:

SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 75-76: truncated \UXXXXXXXX escape

# -*- coding: utf-8 -*-
"""
Created on Wed Mar  3 23:41:08 2021

@author: Hp
Note: Lookup copied to C:\Users\Hp\Aswin\lib\site-packages\utils\__init__.py)


"""
from utils import process_tweet, lookup
import pdb #used for debugging
from nltk.corpus import stopwords, twitter_samples 
import numpy as np
import pandas as pd
import nltk
import string
from nltk.tokenize import TweetTokenizer
from os import getcwd

It's a pain to use # at every line. Please suggest me how to solve this. My python version is - 3.8.3

Aswin Babu
  • 190
  • 1
  • 8
  • 1
    Not getting any errors with the above code (Python 3.9) – Tomerikoo Mar 03 '21 at 18:08
  • 1
    What environment are you running on? Didn't get any errors on 3.8.3 for me. Plus your error is at position 139-140 which is definitely not due the comment string on top of the code. Check out this question: https://stackoverflow.com/questions/39592850/comments-in-python-3-5-giving-unicode-error – Zingerella Mar 03 '21 at 18:09
  • Please [edit] to include the full error traceback as that contains valuable information – G. Anderson Mar 03 '21 at 18:09
  • it should normally not get any errors, but why is it happening in mine! ?. Somehow python is misinterpreting """ as something else – Aswin Babu Mar 03 '21 at 18:10
  • when i remove the commented line Note: Lookup copied to C:\Users\Hp\Aswin\lib\site-packages\utils\__init__.py) the error disappears. – Aswin Babu Mar 03 '21 at 18:17
  • 3
    `\U…` in the path is interpreted as an unicode escape sequence. Use a raw string (`r"""`) to prevent that. – Klaus D. Mar 03 '21 at 18:22
  • @klaus-d this worked. Thank you! – Aswin Babu Mar 03 '21 at 18:46

0 Answers0