Error importing deepspeech pre trained model using python

Hi All,

Hope you are well.

I have downloaded the pre-trained using the terminal instructions and set up the virtual environment.

However, I am having an issue with importing the Deepspeech model using python with the following code

from deepspeech import Model.
Error I get is :

File “/Users/chabani/tmp/deepspeech-venv/bin/Python/untitled0.py”, line 14, in
from deepspeech import Model

ModuleNotFoundError: No module named ‘deepspeech’.

Anyone have an idea as what could be wrong?

Thanks for your assistance

How did you set up the virtual environment? Could you provide each step?

Here is an extract from terminal, I followed the steps from the readme provided by the Mozilla release page:
(base) Chabanis-MacBook-Pro:~ chabani$ virtualenv -p python3 $HOME/tmp/deepspeech-venv/

Running virtualenv with interpreter /Users/chabani/Desktop/Scribe/anaconda3/bin/python3

Already using interpreter /Users/chabani/Desktop/Scribe/anaconda3/bin/python3

Using base prefix ‘/Users/chabani/Desktop/Scribe/anaconda3’

New python executable in /Users/chabani/tmp/deepspeech-venv/bin/python3

Not overwriting existing python script /Users/chabani/tmp/deepspeech-venv/bin/python (you must use /Users/chabani/tmp/deepspeech-venv/bin/python3)

Installing setuptools, pip, wheel…

done.

(base) Chabanis-MacBook-Pro:~ chabani$ source $HOME/tmp/deepspeech-venv/bin/activate

(deepspeech-venv) (base) Chabanis-MacBook-Pro:~ chabani$ source $HOME/tmp/deepspeech-venv/bin/activate

(deepspeech-venv) (base) Chabanis-MacBook-Pro:~ chabani$

(deepspeech-venv) (base) Chabanis-MacBook-Pro:~ chabani$ $ pip3 install deepspeech

-bash: $: command not found

(deepspeech-venv) (base) Chabanis-MacBook-Pro:~ chabani$ pip3 install deepspeech

Requirement already satisfied: deepspeech in ./tmp/deepspeech-venv/lib/python3.7/site-packages (0.5.1)

Requirement already satisfied: numpy>=1.14.5 in ./tmp/deepspeech-venv/lib/python3.7/site-packages (from deepspeech) (1.17.0)

(deepspeech-venv) (base) Chabanis-MacBook-Pro:~ chabani$ pip3 install --upgrade deepspeech

Requirement already up-to-date: deepspeech in ./tmp/deepspeech-venv/lib/python3.7/site-packages (0.5.1)

Requirement already satisfied, skipping upgrade: numpy>=1.14.5 in ./tmp/deepspeech-venv/lib/python3.7/site-packages (from deepspeech) (1.17.0)

I noticed that you’re using both of Anaconda and venv. That might have made your python env a mess. You’d better choose only one of them.

Okay, thanks for the response.

When I use the Python shell to use deepspeech I get the same error as using Anaconda -

from deepspeech.model import Model
Traceback (most recent call last):
File “<pyshell#6>”, line 1, in
from deepspeech.model import Model
ModuleNotFoundError: No module named ‘deepspeech’

from deepspeech import Model
Traceback (most recent call last):
File “<pyshell#7>”, line 1, in
from deepspeech import Model
ModuleNotFoundError: No module named ‘deepspeech’.

Going to back to your suggestion, python and pip are in different locations. My python is in anaconda
(deepspeech-venv) (base) Chabanis-MacBook-Pro:~ chabani$ which python

/Users/chabani/Desktop/Scribe/anaconda3/bin/python

(deepspeech-venv) (base) Chabanis-MacBook-Pro:~ chabani$ which pip

/Users/chabani/tmp/deepspeech-venv/bin/pip.

Would this be an issue as it is not in the Deepspeech venv like PIP. Does python have to be in the same location as deepspeech?

Please excuse me if the question is elementary. Just a noob.

Hi guys, thanks @eggonlea. Sorted out my issue by removing conda and using venv only.

1 Like