Git Product home page Git Product logo

py_translator's Issues

raise JSONDecodeError

Hi, my code is just simply as follows:

import py_translator
from py_translator import Translator
translator = Translator()
translator.translate('bonjour')

I would like to test the package and the text is so short within the limit. But it raise error:
raise JSONDecodeError("Expecting value", s, err.value) from None

and the error message is
JSONDecodeError: Expecting value

sre_constants.error: multiple repeat at position 97

File "/usr/lib/python3.6/site-packages/py_translator/html_connector.py", line 43, in translator
return superTranslator().html(text, lang_to)
File "/usr/lib/python3.6/site-packages/py_translator/html_translator.py", line 217, in html
text = self.tagsReplacer(direction='in', text=text)
File "/usr/lib/python3.6/site-packages/py_translator/html_translator.py", line 164, in tagsReplacer
text = re.sub(link, '(111{})'.format(i), text)
File "/usr/lib64/python3.6/re.py", line 191, in sub
return _compile(pattern, flags).sub(repl, string, count)
File "/usr/lib64/python3.6/re.py", line 301, in _compile
p = sre_compile.compile(pattern, flags)
File "/usr/lib64/python3.6/sre_compile.py", line 562, in compile
p = sre_parse.parse(p, flags)
File "/usr/lib64/python3.6/sre_parse.py", line 855, in parse
p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)
File "/usr/lib64/python3.6/sre_parse.py", line 416, in _parse_sub
not nested and not items))
File "/usr/lib64/python3.6/sre_parse.py", line 619, in _parse
source.tell() - here + len(this))
sre_constants.error: multiple repeat at position 97

dead py_translator again?

#7

packages/py_translator/gtoken.py", line 56, in _update
    self.tkk = self.RE_TKK.findall(r.text)[0]
IndexError: list index out of range

happened this error again.

Exception JSONDecodeError

Hi, I'm trying to run the basic usage example from py-translator's official page and I'm getting the following error:

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Code:

from py_translator import Translator
s = Translator().translate(text='Hello my friend', dest='es').text
print(s)

Python version: 3.5.2
py-translator 1.8.9

Missing requirements

When doing a translation you'll get an error because of uninstalled package:

File "/Users/guydipietro/PycharmProjects/CastleTestUtils/ctvenv/lib/python2.7/site-packages/CastleTestUtils/VoiceUtils/text_to_speech/text_to_speech.py", line 2, in
from py_translator import Translator
File "/Users/guydipietro/PycharmProjects/CastleTestUtils/ctvenv/lib/python2.7/site-packages/py_translator/init.py", line 8, in
from .html_connector import TEXTLIB
File "/Users/guydipietro/PycharmProjects/CastleTestUtils/ctvenv/lib/python2.7/site-packages/py_translator/html_connector.py", line 1, in
from .html_translator import superTranslator, massTranslator, setProxy
File "/Users/guydipietro/PycharmProjects/CastleTestUtils/ctvenv/lib/python2.7/site-packages/py_translator/html_translator.py", line 5, in
from langdetect import detect
ImportError: No module named langdetect

Error when installing py-translator

Hi I'm trying to install py translator using pip however I'm getting the following error:

error in py_translator setup command: Invalid environment marker: python_version >= "3.0"

Not sure why this occurs as my python is > 3.0; any suggestions on how I can fix this?

Python version: 3.4.0
Pip version: 1.5.4
Py-translator version: 1.8.9

Thread error

I got threading error with below code

code:
TEXTLIB().translator(is_html=False, text='aplomb', lang_to='zh-TW', proxy=False)

error message:
image

List index out of range

CODE:
from py_translator import Translator
translator = Translator()
trans = translator.translate('안녕하세요.')
print(trans.text)

ERROR:
Traceback (most recent call last):
File "cleanTweet.py", line 3, in
trans = translator.translate('안녕하세요.')
File "D:\Documents\Code\Storm\src\flask\venv\lib\site-packages\py_translator\client.py", line 172, in translate
data = self._translate(text, dest, src)
File "D:\Documents\Code\Storm\src\flask\venv\lib\site-packages\py_translator\client.py", line 75, in _translate
token = self.token_acquirer.do(text)
File "D:\Documents\Code\Storm\src\flask\venv\lib\site-packages\py_translator\gtoken.py", line 184, in do
self._update()
File "D:\Documents\Code\Storm\src\flask\venv\lib\site-packages\py_translator\gtoken.py", line 56, in _update
self.tkk = self.RE_TKK.findall(r.text)[0]
IndexError: list index out of range

Python version: 3.4.0 (VM) / 3.7.0 (Host)
Pip version: 1.5.4 (VM) / 10.0.1 (Host)
Py-translator version: 1.8.9

dead py_translator?

invoke py_translator.Translator().translate method, an error occured.

  File "/usr/local/lib/python3.6/dist-packages/py_translator/client.py", line 172, in translate
    data = self._translate(text, dest, src)
  File "/usr/local/lib/python3.6/dist-packages/py_translator/client.py", line 75, in _translate
    token = self.token_acquirer.do(text)
  File "/usr/local/lib/python3.6/dist-packages/py_translator/gtoken.py", line 184, in do
    self._update()
  File "/usr/local/lib/python3.6/dist-packages/py_translator/gtoken.py", line 56, in _update
    self.tkk = self.RE_TKK.findall(r.text)[0]

gtoken? right?

by the way, an error occurs also command line not only python code.

$ translate fr <<< 'I think therefore I am'
Traceback (most recent call last):
  File "/home/user/projects/a_soft/venv/lib/python3.6/site-packages/translate/coroutines.py", line 170, in spool
    stream = yield
GeneratorExit

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/projects/a_soft/venv/lib/python3.6/site-packages/translate/coroutines.py", line 145, in set_task
    task = yield
GeneratorExit

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/projects/a_soft/venv/bin/translate", line 11, in <module>
    sys.exit(main())
  File "/home/user/projects/a_soft/venv/lib/python3.6/site-packages/translate/__main__.py", line 115, in main
    return source(spool(set_task(translate, translit=args.translit)), args.text)
  File "/home/user/projects/a_soft/venv/lib/python3.6/site-packages/translate/coroutines.py", line 204, in source
    return target.close()
  File "/home/user/projects/a_soft/venv/lib/python3.6/site-packages/translate/coroutines.py", line 180, in spool
    iterable.close()
  File "/home/user/projects/a_soft/venv/lib/python3.6/site-packages/translate/coroutines.py", line 149, in set_task
    list(map(stream, workers.map(translator, queue)))
  File "/usr/lib/python3.6/concurrent/futures/_base.py", line 586, in result_iterator
    yield fs.pop().result()
  File "/usr/lib/python3.6/concurrent/futures/_base.py", line 432, in result
    return self.__get_result()
  File "/usr/lib/python3.6/concurrent/futures/_base.py", line 384, in __get_result
    raise self._exception
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/user/projects/a_soft/venv/lib/python3.6/site-packages/translate/translator.py", line 51, in connection
    response.raise_for_status()
  File "/home/user/projects/a_soft/venv/lib/python3.6/site-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 503 Server Error: Service Unavailable for url: https://translate.google.com/translate_a/single?client=a&ie=utf-8&oe=utf-8&dt=t&tl=fr&q=I+think+therefore+I+am%0A

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.