abhirooptalasila / AutoSub

A CLI script to generate subtitle files (SRT/VTT/TXT) for any video using either DeepSpeech or Coqui
MIT License
586 stars 102 forks source link

ImportError: attempted relative import with no known parent package #60

Closed andposteo closed 2 years ago

andposteo commented 2 years ago

Hi, my config is Win10_x64, Python 3.8. When i execute $ C:/Soft/Autosub/sub/Scripts/python autosub/main.py --file D:/Work/video.mkv. It gives me error: Traceback (most recent call last): File "autosub/main.py", line 8, in <module> from . import logger Info: `User@Computer MINGW64 /c/Soft/Autosub (master) $ pip list Package Version


absl-py 1.0.0 astunparse 1.6.3 cachetools 4.2.4 certifi 2021.10.8 charset-normalizer 2.0.12 cycler 0.10.0 deepspeech-gpu 0.9.3 distlib 0.3.4 ffmpeg 1.4 filelock 3.6.0 gast 0.3.3 google-auth 1.35.0 google-auth-oauthlib 0.4.6 google-pasta 0.2.0 grpcio 1.44.0 h5py 2.10.0 idna 3.3 importlib-metadata 4.11.3 joblib 0.16.0 Keras-Preprocessing 1.1.2 kiwisolver 1.2.0 Markdown 3.3.6 numpy 1.22.3 oauthlib 3.2.0 opt-einsum 3.3.0 pip 19.2.3 platformdirs 2.5.1 protobuf 3.19.4 pyasn1 0.4.8 pyasn1-modules 0.2.8 pydub 0.23.1 pyparsing 2.4.7 python-dateutil 2.8.1 requests 2.27.1 requests-oauthlib 1.3.1 rsa 4.8 scikit-learn 1.0.2 scipy 1.4.1 setuptools 41.2.0 six 1.15.0 stt 1.0.0 tensorboard 2.2.2 tensorboard-plugin-wit 1.8.1 tensorflow-gpu 2.2.0 tensorflow-gpu-estimator 2.2.0 termcolor 1.1.0 threadpoolctl 3.1.0 tqdm 4.44.1 urllib3 1.26.9 virtualenv 20.13.3 Werkzeug 2.0.3 wheel 0.37.1 wrapt 1.14.0 zipp 3.7.0 WARNING: You are using pip version 19.2.3, however version 22.0.4 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command.`

abhirooptalasila commented 2 years ago

@milahu can you help out here?

milahu commented 2 years ago

yepp ... that's the downside of relative imports (from . import x) you must install the package, so you can run it

git clone --depth 1 https://github.com/abhirooptalasila/AutoSub
cd AutoSub
python3 -m pip install -r requirements.txt
python3 -m pip install -e .
autosub

docs: Python Packaging User Guide » Tutorials » Installing Packages

the advantage of relative imports is: it's easier to install multiple files as a package

milahu commented 2 years ago

to run autosub without install:

git clone --depth 1 https://github.com/abhirooptalasila/AutoSub
cd AutoSub
python3 -m pip install -r requirements.txt # install dependencies: numpy, ...
python3 -m autosub.main

related Relative imports in Python 3

andposteo commented 2 years ago

Thanks for the answer, but i'm newbie. It's not the same to execute one exe file. That's would be nice, even without GUI. Maybe on windows it doesn't work. I still get errors. There is many text. Where i can find spoiler and put it there.

milahu commented 2 years ago

I still get errors.

what errors? what did you try?

MINGW64

you dont need mingw for python

ghost commented 2 years ago

I still have the same issue.

milahu commented 2 years ago

@g3434343 did you try https://github.com/abhirooptalasila/AutoSub/issues/60#issuecomment-1072544886

andposteo commented 2 years ago

Sorry guys. I gave up. The entry threshold is too high, I'm a regular user. I found a solution for myself package "Speech-to-Text" Adobe Premiere Pro 2022. It solved my problem. Please, close the issue. P.S. I liked the ready-made solution for this project, I figured it out without any problems.