Comments (7)
@FidoDidoVN Show your environment, code and error please.
from translators.
Thank you, This is my code:
import translators as ts
Text = "This is my Text"
google = ts.google(Text,to_language="es")
print(google)
sogou = ts.sogou(Text,to_language="es")
print(google)
bing = ts.bing(Text,to_language="es")
print(google)
and the result here:
Este es mi texto
2020-05-19 14:16:08.278 | INFO | translators.apis:wrapper:62 - UseTimeSeconds(fn: google_api): 0.52
Este es mi texto
2020-05-19 14:16:10.471 | INFO | translators.apis:wrapper:62 - UseTimeSeconds(fn: sogou_api): 2.19
Traceback (most recent call last):
File "C:/Users/Fido WIn/Desktop/Fido Json Reup v1.5/test.py", line 8, in
bing = ts.bing(Text,to_language="es")
File "C:\Users\Fido WIn\AppData\Local\Programs\Python\Python37-32\lib\site-packages\translators\apis.py", line 60, in wrapper
r = func(*args, **kwargs)
File "C:\Users\Fido WIn\AppData\Local\Programs\Python\Python37-32\lib\site-packages\translators\apis.py", line 621, in bing_api
data = r.json()
File "C:\Users\Fido WIn\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests\models.py", line 898, in json
return complexjson.loads(self.text, **kwargs)
File "C:\Users\Fido WIn\AppData\Local\Programs\Python\Python37-32\lib\json_init_.py", line 348, in loads
return _default_decoder.decode(s)
File "C:\Users\Fido WIn\AppData\Local\Programs\Python\Python37-32\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\Fido WIn\AppData\Local\Programs\Python\Python37-32\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
from translators.
@FidoDidoVN First, pay attention to your print(*)
. Second, about google
and bing
, you can try if_use_cn_host=False
if you did not more frequently request .
from translators.
Thank you! the error tell that the code is wrong at "line 8, in
bing = ts.bing(Text,to_language="es")" so even my print() is wrong but the code is stop at line 8. I try "if_use_cn_host=False" with the code as:
import translators as ts
Text = "This is my Text"
google = ts.google(Text,to_language="es")
print(google)
sogou = ts.sogou(Text,to_language="es")
print(sogou)
bing = ts.bing(Text,to_language="es",if_use_cn_host=False)
print(bing)
And still get the same error:
Este es mi texto
2020-05-19 15:30:52.411 | INFO | translators.apis:wrapper:62 - UseTimeSeconds(fn: google_api): 0.67
Este es mi texto
2020-05-19 15:30:54.216 | INFO | translators.apis:wrapper:62 - UseTimeSeconds(fn: sogou_api): 1.8
Traceback (most recent call last):
File "C:/Users/Fido WIn/Desktop/Fido Json Reup v1.5/test.py", line 8, in
bing = ts.bing(Text,to_language="es",if_use_cn_host=False)
File "C:\Users\Fido WIn\AppData\Local\Programs\Python\Python37-32\lib\site-packages\translators\apis.py", line 60, in wrapper
r = func(*args, **kwargs)
File "C:\Users\Fido WIn\AppData\Local\Programs\Python\Python37-32\lib\site-packages\translators\apis.py", line 621, in bing_api
data = r.json()
File "C:\Users\Fido WIn\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests\models.py", line 898, in json
return complexjson.loads(self.text, **kwargs)
File "C:\Users\Fido WIn\AppData\Local\Programs\Python\Python37-32\lib\json_init_.py", line 348, in loads
return _default_decoder.decode(s)
File "C:\Users\Fido WIn\AppData\Local\Programs\Python\Python37-32\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\Fido WIn\AppData\Local\Programs\Python\Python37-32\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
from translators.
@FidoDidoVN The error is No data returned by network request . Where are you from? And pip install translators --upgrade
, ensure the version is 4.5.4
from translators.
I'm from Viet Nam. Yes my version is 4.5.4.
from translators.
@FidoDidoVN So you should use if_use_cn_host=False
for bing()
. Can you access this website(http://bing.com/Translator) normally and translate it normally?
from translators.
Related Issues (20)
- [Bug]: raise TranslatorError('Google service was offline in inland of China on Oct 2022.') HOT 1
- [Bug]: translator caiyun: AttributeError: 'NoneType' object has no attribute 'group' HOT 4
- [Feature]: Normalized translation return object/dict HOT 2
- [Feature]: Return the chosen language (handy when using 'auto') HOT 2
- [Bug]: "The `query_text` can't be empty!" in translate_html HOT 1
- [Bug]: workaround of consent.google.com doesn't work anymore HOT 11
- [Feature]: Translation services (eg Bing) easily rate limited HOT 1
- [Bug]: translator server - google: language map is empty so getting error "Unsupported from_language[ar] in []" HOT 24
- [Bug]: Python 3 doesn't like re with Positive Lookbehind ? HOT 2
- [Bug]: KeyError: 'data' when using baidu HOT 2
- [Bug]: "Using region <name> server backend." printed on stdout HOT 1
- [Feature]: Georgian language HOT 1
- [Bug]: translate_html strips whitespace HOT 1
- [Bug]: Misleading error message HOT 1
- [Bug]: iciba not working now HOT 2
- [Feature]: 统一所有翻译器的源语言代码和目标语言代码 HOT 2
- [Bug]: Unable to find server backend. HOT 1
- [Bug]: crash HOT 3
- [Bug]: The function baidu() has been not certified yet HOT 3
- [Bug]: 504 Server Error: Gateway Time-out for url: https://aidemo.youdao.com/trans HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from translators.