Comments (11)
Sorry to bump into the conversation, but I got the same error (I'm sure the key was copied correctly).
I opened a ticket as @daniel-jones-deepl suggests, but since I'm having this issue as well, maybe there is an underlying bug here.
Hope this info is useful for you
EDIT: The problem was caused by the fact that my plan is not compatible with the API usage, but only with CAT tool. I apology for the post
from deepl-python.
Hi @unnidiametos, there might be a simple fix: in case your file is named "deepl.py", try renaming it, for example: "my_deepl_script.py".
If that doesn't fix it, can you please provide an example that reproduces the error, and say which Python version you are using?
from deepl-python.
It is still producing the same error after renaming. I am using python 3.9.0
from deepl-python.
Okay, then can you please share a minimal example file that produces your problem? Please make sure that your auth-key is not included.
from deepl-python.
import deepl
auth_key = {
'host' : "https://api.deepl.com/v2/translate?",
'auth_key': "xxxxxxxxxxxxxxxxxxxxxxxxxxx"}
text = "Wie geht es dir?"
target_language = "EN-US"
translator = deepl.Translator(auth_key['auth_key'])
result = translator.translate_text(text, target_lang=target_language)
translated_text = result.text
print(translated_text)
from deepl-python.
Thank you for sharing the example. I don't see anything wrong with your example, and it works fine for me.
Maybe you have another file in the same directory named "deepl.py", or a directory named "deepl"? This would cause the import error you are seeing.
from deepl-python.
Thanks for the comment. I recognized that the folder name was 'deepl'. When I changed it the import is working.
But when I got to
result = translator.translate_text(text, target_lang=target_language)
I am getting error as:
Traceback (most recent call last):
File "C:\Users\unnik\OneDrive\Desktop\my_deepl\my_deepl_script.py", line 10, in
result = translator.translate_text(text, target_lang=target_language)
File "C:\Users\unnik\AppData\Local\Programs\Python\Python39\lib\site-packages\deepl\translator.py", line 504, in translate_text
request_data = self._check_language_and_formality(
File "C:\Users\unnik\AppData\Local\Programs\Python\Python39\lib\site-packages\deepl\translator.py", line 428, in _check_language_and_formality
self._check_valid_languages(source_lang, target_lang)
File "C:\Users\unnik\AppData\Local\Programs\Python\Python39\lib\site-packages\deepl\translator.py", line 411, in _check_valid_languages
target_lang == lang.code for lang in self.get_target_languages()
File "C:\Users\unnik\AppData\Local\Programs\Python\Python39\lib\site-packages\deepl\translator.py", line 745, in get_target_languages
self._target_languages_cached = self._request_languages(
File "C:\Users\unnik\AppData\Local\Programs\Python\Python39\lib\site-packages\deepl\translator.py", line 375, in _request_languages
self._raise_for_status(status, content, json)
File "C:\Users\unnik\AppData\Local\Programs\Python\Python39\lib\site-packages\deepl\translator.py", line 345, in _raise_for_status
raise AuthorizationException(
deepl.exceptions.AuthorizationException: Authorization failure, check auth_key
Could you please help me with this also
from deepl-python.
Great that the first problem is solved.
To solve this AuthorizationException, you could check that your authentication key is exactly as it appears on your DeepL Pro Account page - check you don't have leading or trailing spaces, for example.
If you still have problems with authorization, you could submit a support request, so that we can check your authentication key.
from deepl-python.
Hi @LivingDeadCloud, no problem, thank you for commenting about your problem.
from deepl-python.
Is there any other reason why this problem might occur?
I am working with DeepL in the Pythonanywhere cloud and have installed the package correctly.
However when I run my script I only get the following error
"/home/alexjeser/.virtualenvs/gpt3x/gcm_reviews_gpt3y.py", line 23, in <module> translator = deepl.Translator(auth_key) AttributeError: module 'deepl' has no attribute 'Translator'
Any advice?
I don't have any other script or directory or folder which is called "deepl" or "deepl.py".
from deepl-python.
Hi @blacchollywood, to eliminate the possibility of importing the wrong module, you could try inspecting deepl.__file__
; it should be a filepath ending in deepl/__init__.py
, and the file itself should begin with the line # Copyright 2022 DeepL SE (https://www.deepl.com)
.
If this is all as expected, then there could be an issue with the library in PythonAnywhere.
from deepl-python.
Related Issues (20)
- [Bug] DeepL Write adds sentences describing chosen style
- DeepL documentation states ZH is supported as target for translate_docs but on execution it errors HOT 2
- translate_document_from_filepath fails to recognise XML files HOT 1
- Error: Bad request, message: Document is empty HOT 4
- [Feature Request] Make auto-retry toggleable HOT 3
- can't use my auth key, and can't sign up to the API plan for free trial HOT 4
- preserve_formatting missing in translate_document() function HOT 5
- In the translation result, the "left" quotation mark is missing. HOT 1
- Convenient request max retries setup HOT 4
- Encoding problem when translating to french. HOT 2
- New feature : customize timeout duration HOT 2
- Glossaries HOT 1
- deepl.Formality.MORE results in untranslated text HOT 1
- Mismatch in the placement of ignore tags and lack of translation HOT 1
- The deepl.Formality is ignored
- Abnormal strings in translation results: ãã£ã£ãç§ã¡ã¡åã HOT 5
- `translate_document()` should `seek(0, 0)` the output file after being done
- Disambiguate homonyms in glossaries / provide alternative translations? HOT 3
- When translating long English fields into Chinese, the last paragraph was lost
- Glossary flexible search
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 deepl-python.