3

I saved a model using cPickle using this code below

picklefile = path.split("-")[0]+".gmm"
cPickle.dump(gmm,open(dest + picklefile,'w'))
print '+ modeling completed for speaker:',picklefile," with data point = ",features.shape    
features = np.asarray(())
count = 0 

Now I want to unpickle the file using this method

models    = [cPickle.load(open(fname,'r')) for fname in gmm_files]

But I get this error:

models    = [cPickle.load(open(fname,'r')) for fname in gmm_files]
ImportError: No module named gmm

I expect the output to unpickle the saved file

alec_djinn
  • 10,104
  • 8
  • 46
  • 71
Tolu
  • 121
  • 8
  • Mind that `cPickle` and `pickle` are two different things. Also, you should write the dump in binary mode `'wb'`. – alec_djinn Jan 11 '19 at 11:00
  • When I use cPickle to unpickle it models = [cPickle.load(open(fname,'r')) for fname in gmm_files].... I get this error ImportError: No module named gmm – Tolu Jan 11 '19 at 11:08
  • The pickled object was created by a program that did `import gmm`. In order to recreate that object in your program, the `gmm` module must be available, and it looks like it isn't. If it is a module of your own, then you need to put its location in `PYTHONPATH` (or `sys.path`), or copy `gmm.py` to the folder where you are working. – BoarGules Jan 11 '19 at 11:43
  • I have downloaded gmm.py file and kept it in my working directory, it imports well but I still get the ImportError: No module named gmm error – Tolu Jan 11 '19 at 12:05
  • Is the import done globally or locally inside another code block? – Kenstars Jan 11 '19 at 13:10
  • I'm importing it globally, I also tried importing from sklearn.mixture import GaussianMixture as gmm and i still get the same error."No module named gmm" – Tolu Jan 11 '19 at 14:23

0 Answers0