Giter Club home page Giter Club logo

Comments (11)

LivingDeadCloud avatar LivingDeadCloud commented on July 20, 2024 1

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.

daniel-jones-deepl avatar daniel-jones-deepl commented on July 20, 2024

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.

unnidiametos avatar unnidiametos commented on July 20, 2024

It is still producing the same error after renaming. I am using python 3.9.0

from deepl-python.

daniel-jones-deepl avatar daniel-jones-deepl commented on July 20, 2024

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.

unnidiametos avatar unnidiametos commented on July 20, 2024

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.

daniel-jones-deepl avatar daniel-jones-deepl commented on July 20, 2024

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.

unnidiametos avatar unnidiametos commented on July 20, 2024

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.

daniel-jones-deepl avatar daniel-jones-deepl commented on July 20, 2024

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.

daniel-jones-deepl avatar daniel-jones-deepl commented on July 20, 2024

Hi @LivingDeadCloud, no problem, thank you for commenting about your problem.

from deepl-python.

blacchollywood avatar blacchollywood commented on July 20, 2024

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.

daniel-jones-deepl avatar daniel-jones-deepl commented on July 20, 2024

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)

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.