TextBlob: HTTP Error 503: Service Unavailable while using detect_language() and translate() from textblob

python:3.5 textblob:0.15.1

seems it happened before and fixed in #148

the detail logs File "/usr/local/lib/python3.5/site-packages/textblob/blob.py", line 562, in detect_language return self.translator.detect(self.raw) File "/usr/local/lib/python3.5/site-packages/textblob/translate.py", line 72, in detect response = self._request(url, host=host, type_=type_, data=data) File "/usr/local/lib/python3.5/site-packages/textblob/translate.py", line 92, in _request resp = request.urlopen(req) File "/usr/local/lib/python3.5/urllib/request.py", line 163, in urlopen return opener.open(url, data, timeout) File "/usr/local/lib/python3.5/urllib/request.py", line 472, in open response = meth(req, response) File "/usr/local/lib/python3.5/urllib/request.py", line 582, in http_response 'http', request, response, code, msg, hdrs) File "/usr/local/lib/python3.5/urllib/request.py", line 504, in error result = self._call_chain(*args) File "/usr/local/lib/python3.5/urllib/request.py", line 444, in _call_chain result = func(*args) File "/usr/local/lib/python3.5/urllib/request.py", line 696, in http_error_302 return self.parent.open(new, timeout=req.timeout) File "/usr/local/lib/python3.5/urllib/request.py", line 472, in open response = meth(req, response) File "/usr/local/lib/python3.5/urllib/request.py", line 582, in http_response 'http', request, response, code, msg, hdrs) File "/usr/local/lib/python3.5/urllib/request.py", line 510, in error return self._call_chain(*args) File "/usr/local/lib/python3.5/urllib/request.py", line 444, in _call_chain result = func(*args) File "/usr/local/lib/python3.5/urllib/request.py", line 590, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp)

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 5
  • Comments: 21 (5 by maintainers)

Most upvoted comments

Again, please do not post any more “+1” comments. I encourage anyone to send a PR resolving this.

Please do not post “+1” or “me too” comments, as they are not constructive.

I would welcome a PR addressing this issue, or even just an analysis of the problem with a possible solution.

I think it’s time we remove the language detection and translate features. They use an undocumented/unsupported Google API, which is why they no longer work.

An offline and a decent language detector which worked for my case: langid

Sample code: _import langid as lid lang,conf = lid.classify(word) if conf > threshold: print(‘%s word belongs to %s language’%(word, lang))

PS: If you are trying to classify only English words 👍 this helps a lot but not much of help for other languages 👎

Thank you.

A temporary workaround for detect_language could be using the port langdetect. Could run the code bellow without the HTTP Error 503.

from langdetect import detect
for i in range(1000):
    print(detect('Hello World'))

Keep in mind that this doesn’t solve the error in translate method.

EDIT: Typo

I have the same problem with my code. I belive this error migth be happeing due to Google isn’t free anymore. So they let you to compute some tanslations untill they reject you from the server.

I changed my ip, and it let me try more words , but when It reached the maximun(418 words translated), it denied the connection again. So that’s my guess

Some people in others issue has said the same as me.