Skip to content
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

[Bug]: TypeError: 'type' object is not subscriptable #596

Open
Tianci-King opened this issue Mar 29, 2024 · 2 comments
Open

[Bug]: TypeError: 'type' object is not subscriptable #596

Tianci-King opened this issue Mar 29, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@Tianci-King
Copy link

Tianci-King commented Mar 29, 2024

Issue

I've gone through the installation steps for dependencies as outlined in your readme document, yet I'm facing the issue
about "TypeError: 'type' object is not subscriptable" . ** I had installed all the requires** , but it did not worked. My python version is 3.8.13. I would greatly appreciate your assistance !

iShot_2024-03-29_16 32 37
Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniconda/base/envs/imagetranslator/lib/python3.8/runpy.py", line 185, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/opt/homebrew/Caskroom/miniconda/base/envs/imagetranslator/lib/python3.8/runpy.py", line 144, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/opt/homebrew/Caskroom/miniconda/base/envs/imagetranslator/lib/python3.8/runpy.py", line 111, in _get_module_details
    __import__(pkg_name)
  File "/Users/tiancy/project/manga-image-translator/manga_translator/__init__.py", line 7, in <module>
    from .manga_translator import *
  File "/Users/tiancy/project/manga-image-translator/manga_translator/manga_translator.py", line 23, in <module>
    from .args import DEFAULT_ARGS, translator_chain
  File "/Users/tiancy/project/manga-image-translator/manga_translator/args.py", line 8, in <module>
    from .translators import VALID_LANGUAGES, TRANSLATORS, TranslatorChain
  File "/Users/tiancy/project/manga-image-translator/manga_translator/translators/__init__.py", line 14, in <module>
    from .mbart50 import MBart50Translator
  File "/Users/tiancy/project/manga-image-translator/manga_translator/translators/mbart50.py", line 31, in <module>
    class MBart50Translator(OfflineTranslator):
  File "/Users/tiancy/project/manga-image-translator/manga_translator/translators/mbart50.py", line 79, in MBart50Translator
    async def _infer(self, from_lang: str, to_lang: str, queries: list[str]) -> list[str]:
TypeError: 'type' object is not subscriptable
@Tianci-King Tianci-King added the bug Something isn't working label Mar 29, 2024
@Tianci-King Tianci-King changed the title [Bug]: I have the same bug in https://github.com/zyddnys/manga-image-translator/issues/423 [Bug]: TypeError: 'type' object is not subscriptable Mar 29, 2024
@Tianci-King Tianci-King reopened this Mar 29, 2024
@grassroadsZ
Copy link

`from typing import List

async def _infer(self, from_lang: str, to_lang: str, queries: List[str]) -> List[str]:
if from_lang == 'auto':
detected_lang = langid.classify('\n'.join(queries))[0]
target_lang = self._map_detected_lang_to_translator(detected_lang)

    if target_lang == None:
        self.logger.warn('Could not detect language from over all sentence. Will try per sentence.')
    else:
        from_lang = target_lang

return [self._translate_sentence(from_lang, to_lang, query) for query in queries]

`
this code can work

@AI-confused
Copy link

List[str] modify to List
this can work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants