Pickle problem while loading a class instance.

gerardob gberbeglia at gmail.com
Tue Apr 6 13:23:56 EDT 2010

Hello, I am new to python and i have a problem using the pickle load
I have an object m of the class MarkovModel and i want to copy it to a file
and load it onto another class:

m = markov_model.MarkovModel()
file = open("prueba.txt", 'w')

#m2 = markov_model.MarkovModel()

file = open("prueba.txt", 'rb')
m2 = pickle.load(file) (THIS IS LINE 36)

The error below appears. In the case i remove the comment to initialize m2,
the same thing happens. Any ideas on how to fix this?


Traceback (most recent call last):
File "C:\Users\gberbeglia\Documents\python\scripting\mycodes\main.py", line
36, in <module>
m2 = pickle.load(file)
File "C:\Python26\lib\pickle.py", line 1370, in load
return Unpickler(file).load()
File "C:\Python26\lib\pickle.py", line 858, in load
File "C:\Python26\lib\pickle.py", line 1090, in load_global
klass = self.find_class(module, name)
File "C:\Python26\lib\pickle.py", line 1124, in find_class
ImportError: No module named markov_model
View this message in context: http://old.nabble.com/Pickle-problem-while-loading-a-class-instance.-tp28154964p28154964.html
Sent from the Python - python-list mailing list archive at Nabble.com.

More information about the Python-list mailing list