apm1467 / videocr

Extract hardcoded subtitles from videos using machine learning
MIT License
506 stars 117 forks source link

AttributeError: module 'videocr' has no attribute 'get_subtitles' #4

Closed Wizek closed 4 years ago

Wizek commented 4 years ago

What could be the problem here?

PS C:\Users\Wizek\sandbox> tesseract --version
tesseract v5.0.0-alpha.20190708
 leptonica-1.78.0
  libgif 5.1.4 : libjpeg 8d (libjpeg-turbo 1.5.3) : libpng 1.6.34 : libtiff 4.0.9 : zlib 1.2.11 : libwebp 0.6.1 : libopenjp2 2.3.0
 Found AVX2
 Found AVX
 Found SSE
 Found libarchive 3.3.2 zlib/1.2.11 liblzma/5.2.3 bz2lib/1.0.6 liblz4/1.7.5

PS C:\Users\Wizek\sandbox> pip3.7 install videocr
Requirement already satisfied: videocr in c:\users\wizek\appdata\local\programs\python\python37-32\lib\site-packages (0.1.5)
Requirement already satisfied: fuzzywuzzy>=0.17 in c:\users\wizek\appdata\local\programs\python\python37-32\lib\site-packages (from videocr) (0.17.0)
Requirement already satisfied: python-Levenshtein>=0.12 in c:\users\wizek\appdata\local\programs\python\python37-32\lib\site-packages (from videocr) (0.12.0)
Requirement already satisfied: opencv-python<5.0,>=4.1 in c:\users\wizek\appdata\local\programs\python\python37-32\lib\site-packages (from videocr) (4.1.1.26)
Requirement already satisfied: pytesseract>=0.2.6 in c:\users\wizek\appdata\local\programs\python\python37-32\lib\site-packages (from videocr) (0.3.0)
Requirement already satisfied: setuptools in c:\users\wizek\appdata\local\programs\python\python37-32\lib\site-packages (from python-Levenshtein>=0.12->videocr) (41.2.0)
Requirement already satisfied: numpy>=1.14.5 in c:\users\wizek\appdata\local\programs\python\python37-32\lib\site-packages (from opencv-python<5.0,>=4.1->videocr) (1.17.2)
Requirement already satisfied: Pillow in c:\users\wizek\appdata\local\programs\python\python37-32\lib\site-packages (from pytesseract>=0.2.6->videocr) (6.1.0)
You are using pip version 19.0.3, however version 19.2.3 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

PS C:\Users\Wizek\sandbox> py -3.7 .\videocr.py
Traceback (most recent call last):
  File ".\videocr.py", line 4, in <module>
    print(videocr.get_subtitles('1.avi', lang='eng', sim_threshold=70, conf_threshold=65))
AttributeError: module 'videocr' has no attribute 'get_subtitles'
PS C:\Users\Wizek\sandbox>

.\videocr.py:

import videocr

if __name__ == '__main__':
    print(videocr.get_subtitles('1.avi', lang='eng', sim_threshold=70, conf_threshold=65))

Could this be some simple python thing I am missing or mixing up? I'm not very experienced with python.

Wizek commented 4 years ago

Hah, I've found the problem! Just needed to rename my test file from .\videocr.py to anything else; in my case I named it .\videocr1.py. Then the import was working. Didn't know this was how python modules worked, and that indeed they could shadow each other. Sorry if this bothered you.

apm1467 commented 4 years ago

Congratulations that you solved this on your own!