UlionTse / translators

🌏🌍🌎Translators🌎🌍🌏 is a library that aims to bring free, multiple, enjoyable translations to individuals and students in Python. Translators是一个旨在用Python为个人和学生带来免费、多样、愉快翻译的库。
https://pypi.org/project/translators/
GNU General Public License v3.0
1.62k stars 189 forks source link

[Bug]: JSONDecodeError: Expecting value: line 1 column 1 (char 0) #122

Closed GingerNg closed 1 year ago

GingerNg commented 1 year ago

Debug Tips

What happened?

A bug happened! python3.8.10

APP Version

0.0.1(example)

Python Version

=3.6, <=3.8

Runtime Environment

Linux Ubuntu

Country/Region

China

Relevant log output

Output exceeds the size limit. Open the full output data in a text editor---------------------------------------------------------------------------
JSONDecodeError                           Traceback (most recent call last)
File /data1/ginger/Livat/.venv/lib/python3.8/site-packages/requests/models.py:971, in Response.json(self, **kwargs)
    970 try:
--> 971     return complexjson.loads(self.text, **kwargs)
    972 except JSONDecodeError as e:
    973     # Catch JSON-related errors and raise as requests.JSONDecodeError
    974     # This aliases json.JSONDecodeError and simplejson.JSONDecodeError

File /usr/lib/python3.8/json/__init__.py:357, in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    354 if (cls is None and object_hook is None and
    355         parse_int is None and parse_float is None and
    356         parse_constant is None and object_pairs_hook is None and not kw):
--> 357     return _default_decoder.decode(s)
    358 if cls is None:

File /usr/lib/python3.8/json/decoder.py:337, in JSONDecoder.decode(self, s, _w)
    333 """Return the Python representation of ``s`` (a ``str`` instance
    334 containing a JSON document).
    335 
    336 """
--> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    338 end = _w(s, end).end()

File /usr/lib/python3.8/json/decoder.py:355, in JSONDecoder.raw_decode(self, s, idx)
...
    973     # Catch JSON-related errors and raise as requests.JSONDecodeError
    974     # This aliases json.JSONDecodeError and simplejson.JSONDecodeError
--> 975     raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Screenshots

![](https://s2.loli.net/2023/04/25/5KMTtdJyWzno8AH.png)

Code of Conduct

UlionTse commented 1 year ago

Hello, I saw your error logs, please provide what your input and your source code, so that we can repeat and solve the problem.

Aakashagr commented 11 months ago

Hello, I am experiencing a similar issue when I run the follow code

import translators as ts
ts.translate_text('good',to_language='fr')

It often works with google translator but I am not sure what is the issue with bing

UlionTse commented 11 months ago

@Aakashagr Bro, this is caused by the masculine and feminine of the French word, bing's output at this time is html, not the regular json data, so it is recommended that you translate the sentence, not the word.

Aakashagr commented 11 months ago

@UlionTse, this issue occurs even with the sentence.. Try this out

ts.translate_text('The mall is crowded with shoppers on weekends.',to_language = 'fr')
UlionTse commented 11 months ago

@Aakashagr

translators20231002
Aakashagr commented 11 months ago

But why can't the output be any one of the two sentences instead of showing an error

UlionTse commented 11 months ago

Prefer to translate which one, masculine or feminine?

Aakashagr commented 11 months ago

Let's say Masculine.

On Tue, 3 Oct 2023 at 17:11, UlionTse @.***> wrote:

Prefer to translate which one, masculine or feminine?

— Reply to this email directly, view it on GitHub https://github.com/UlionTse/translators/issues/122#issuecomment-1745180646, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADCY3UMVTFMS2O7R4UOACCLX5QTITAVCNFSM6AAAAAAXKUR5J2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBVGE4DANRUGY . You are receiving this because you were mentioned.Message ID: @.***>

UlionTse commented 11 months ago

Okay.

UlionTse commented 11 months ago

@Aakashagr Bro, please pip install --upgrade translators==5.8.6.

Aakashagr commented 11 months ago

@UlionTse, thanks bro. This version works perfectly

UlionTse commented 11 months ago

@Aakashagr You are welcome.