mrf345 / django_gtts

Django app extension to add gTTS google text-to-speech
MIT License
7 stars 8 forks source link

can not use django_gtts, getting ModuleNotFoundError: #12

Open almehady opened 3 years ago

almehady commented 3 years ago

Hello Dev,

thanks for making djagno gtts app. I'm trying to integrate with my django project (following your instruction) but getting the following error:

return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'gTTS'

FYI - I'm already using gTTS app with my project and it's working fine.

Your suggestion will be highly appreciated.

Happy coding.

thanks. AM.

velllum commented 3 years ago

День добрый В приложении надо исправить строку: if not isfile(path.join(temp_path, ext_file.file_name)): на if not path.isfile(path.join(temp_path, ext_file.file_name)): иначе получаем ошибку "Exception name 'isfile' is not defined"

OmegaHawkeye commented 3 years ago

Hello, having the same problem . Pls give a proper solution on how to fix it. I rlly want to use it since i think its a great package.

Thx in advance for any help OmegaHawkeye

velllum commented 3 years ago

Файл для правки лежит здесь : venv/lib/python3.6/site-packages/gTTS/templatetags/gTTS.py

В нем надо исправить строку: if not isfile(path.join(temp_path, ext_file.file_name)): на if not path.isfile(path.join(temp_path, ext_file.file_name)):

Обратиться к методу isfile через импортируемый path (из строки выше from os import path, makedirs, remove ) библиотеки os

OmegaHawkeye commented 3 years ago

I already did that but as soon as I add 'gTTS' to installed apps or to the urls it throws an error like this:

return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'gTTS'

I researched and it might be bc the File is named like the module 'gTTS' u r using.

Would be great if u get that fixed. Thx in advance, OmegaHawkeye

iz3n commented 10 months ago

I fixed it with editing some source in your env/Lib/site-packages/gtts/init.py add this code

from .version import __version__ 
from .tts import gTTS, gTTSError

__all__ = ["__version__", "gTTS", "gTTSError"]

and in settings.py you need change gTTS to gtts and same for urls this work for me

i just wanted to use template tag {% say %} and this changes make it happend