-1

I am using vosk to compare user voice and given text to read, and print out an accuracy json. I am able to run vosk separately via the terminal and get results. But when i try to run it through flask i get the following error.

flask.cli.NoAppException: While importing "app", an ImportError was raised:

Traceback (most recent call last):
File "/home/prks18/.local/lib/python3.8/site-packages/flask/cli.py", line 240, in locate_app
__import__(module_name)
File "/home/CODE/Flask/app.py", line 5, in <module>
from vosk import aligner
ImportError: cannot import name 'aligner' from 'vosk' (/home/myfolder/.local/lib/python3.8/site-packages/vosk/__init__.py)

` i found out that flask is trying to get the package from python3.8 folder while the aligner package is in /usr/local/lib/python3.10/site-packages/vosk-0.3.32-py3.10.egg/vosk/aligner/init.py

How to make flask grab it from the latter folder?

davidism
  • 121,510
  • 29
  • 395
  • 339
Prakash R
  • 23
  • 4
  • You don't just make it "grab from the latter folder", because this package is designed for Python 3.10, not 3.8. Either install vosk for the version of Python Flask is using or change the version it is using to the one with vosk installed. – matszwecja Mar 21 '22 at 13:28
  • @matszwecja can you please tell me how to change the python version of flask, reinstalling flask would work? – Prakash R Mar 21 '22 at 13:33
  • You need to uninstall it form 3.8 modules and install as a 3.10 one. That might need some changes in PATH envvar. – matszwecja Mar 21 '22 at 13:35
  • Thanks @matszwecja , i reinstalled flask and vosk for python 3.10 and it works !. Thank you for your time. – Prakash R Mar 21 '22 at 16:14

1 Answers1

0

I, suggest you to consider using a virtual environment, so that package installation can be constrained to a particular Python version, instead of choosing the system default, as,

virtualenv -p python3.10 venv
Henshal B
  • 1,540
  • 12
  • 13