manga-image-translator
manga-image-translator copied to clipboard
[Bug]: TypeError: 'type' object is not subscriptable
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 !
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
`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
List[str] modify to List this can work
May I ask if this problem has been resolved? I also encountered the same error,