I import vtt_to_srt converter.I read the instructions.I make the installation.From beginning to this "no problem" but when I import it as manuals describe python can't find the module there. Installation
pip install vtt_to_srt3
Usage
from vtt_to_srt import vtt_to_srt
path = '/path/to/file.vtt'
vtt_to_srt(path)
Error
ImportError: cannot import name 'vtt_to_srt' from 'vtt_to_srt'
I am a rookie.Sorry for asking this question.
@SakuraFreak's answer was my immediate thought, too, but I ended up investigating this a bit further. It seems like vtt_to_srt
stores all its API in the __main__.py
file of the module. This file should normally be used when you want to a module using python -m
.
This actually makes the module impossible to use the way that the documentation specifies. What I tried, then was:
from vtt_to_srt.__main__ import vtt_to_srt
print(vtt_to_srt)
This results in:
<function vtt_to_srt at 0x000002A0948216A8>
So it seems like this workaround is OK.
I do not know if storing all the module's code in __main__.py
is some convention not supported by my version of Python (CPython 3.7.3 on Windows), or if it simply an error. Maybe you should approach the module's owners with this.