-
Notifications
You must be signed in to change notification settings - Fork 729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: the JSON object must be str, bytes or bytearray, not NoneType #301
Comments
我遇到了同样的报错,经过检测发现是翻译的字符数超过5000或者传入的是""空字符串就会有这样的报错。但API文档中显示单个文本最大翻译字符上限为15K,我也有点迷糊,想到issue中寻找答案来着,,, |
I believe you encounter this issue because your text is too long.I think documentation says the character limit is15k but I encounter the same problem when I send anything longer than 5k. Try to send your text in 5k chunks and see if you still have the issue. Make sure the chunks end with complete sentences tho. Then you can concatenate the results |
Your content is too long, I recommend using something smaller than 5000 as mentioned above.
|
Apparently this error also occurs when a bunch of whitespace / no content to actually translate is present. Something to keep in mind. |
if yall cant get this working, you can try this instead #268 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I'm getting this error with just the README's example of bulk translating. translations = translator.translate(['The quick brown fox', 'jumps over', 'the lazy dog'], dest='ko') the entire error message:
only bulk translating doesn't work however. Translating normally works just fine. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
It also happens if the string is empty. I translate from a JSON file, add this line before translating: if sourceTranslation == "" or sourceTranslation is None: |
result=df.to_json(orient="index",default_handler=str).encode('utf-8') |
I am trying to get the source language from a sentence:
i get the following Error:TypeError Traceback (most recent call last) in () 2 frames /usr/local/lib/python3.7/dist-packages/googletrans/client.py in detect(self, text) /usr/local/lib/python3.7/dist-packages/googletrans/client.py in translate(self, text, dest, src) /usr/lib/python3.7/json/init.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw) TypeError: the JSON object must be str, bytes or bytearray, not NoneType |
File "/data/leisu/leisu_env/lib/python3.7/site-packages/googletrans/client.py", line 219, in translate
parsed = json.loads(data[0][2])
File "/data/local/python3.7/lib/python3.7/json/init.py", line 341, in loads
raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not NoneType
The text was updated successfully, but these errors were encountered: