Why do I get an HTTP Error 400 when using TextBlob and how can i resolve?

116 Views Asked by At

I am experiencing some problems using the TextBlob library. I'm trying to run a very simple piece of code like this:

from textblob import TextBlob

text1 = TextBlob('I looked for Mary and Samantha at the bus station')
a = text1.detect_language()
print(a)

And it continually gives me this error:

``
    639 class HTTPDefaultErrorHandler(BaseHandler):
    640     def http_error_default(self, req, fp, code, msg, hdrs):
--> 641         raise HTTPError(req.full_url, code, msg, hdrs, fp)
    642 
    643 class HTTPRedirectHandler(BaseHandler):

HTTPError: HTTP Error 400: Bad Request
``
1

There are 1 best solutions below

0
AudioBubble On

oh try using:

    from textblob.translate import Translator

    translate = Translator()
    text1 = 'I looked for Mary and Samantha at the bus station'
    a = translate.detect(text1)
    print(a)

that works for me