Python module ImportError: No module named pocketsphinx

Came across the error while experimenting with pocketsphinx – CMU Speech Recognition Kit.

Modules already installed by package manager:
python-pocketsphinx
pocketsphinx-hmm-wsj1
pocketsphinx-lm-wsj

Python shell is able to locate libs

help(‘pocketsphinx’) & dir(‘pocketsphinx’) works fine on the python shell, but importing it in the external script blows up with the below error:

Traceback (most recent call last):
 File "pythonPocketSphinxTest2.py", line 6, in < module >
 import pocketsphinx
 ImportError: No module named pocketsphinx

Quick fix:
The system is not able to find the python libs, just provide PYTHONPATH to system path.

vi ~/.bashrc
Add below lines:

export PYTHONPATH=/usr/lib/pymodules/python2.7 
export PATH=$PATH:$PYTHONPATH

Save and exit.
source ~/.bashrc

Thats It. We are done here. Cheers.

Note: Add the PYTHONPATH accordingly as where your python is present.

2 thoughts on “Python module ImportError: No module named pocketsphinx”

  1. Pingback: Python – No module named fooCopyQuery CopyQuery | Question & Answer Tool for your Technical Queries,CopyQuery, ejjuit, query, copyquery, copyquery.com, android doubt, ios question, sql query, sqlite query, nodejsquery, dns query, update query, i

Leave a Reply

Your email address will not be published. Required fields are marked *