I am unable to access imported models attribute

58 views Asked by At
import pocketsphinx 
for phrase in pocketsphinx.LiveSpeech():print(phrase)

So the weirdest thing ever happened. This code worked fine. Then I cut and pasted it into another python file in the same project and boom I get, AttributeError: module 'pocketsphinx' has no attribute 'LiveSpeech'. pocketsphinx is in my external libraries and my ide recognizes it, but now there is no autocomplete options with pocketsphinx.(should have recommendations). So this is weird. When I cut and past back to old file it does not work either now. ??? Hmm... Why

1

There are 1 answers

0
mata On

This kind of error often happens when there is a module in the project directory with the same name as the one being imported. This file is then found earlier when traversing sys.path, so it shadows the library you're trying to import.

So in this case you probably have a file pocketsphinx.py within your project directory. If you rename that to something else then it should work.