Ivan Pudyakov
Ivan Pudyakov

Reputation: 116

Error with pickle module. AttributeError: class has no attribute '__new__'

I have been used python and Abaqus for a long time. But when i upgraded my python from 2.7 to 3.5.2 some error occures. I try to pickle some object A of my class.

    f = open(utilsDir + "aclass.log", 'wb')
    pickle.dump(A,f,protocol=2)
    f.close()

and then unpickle it with abaqus' python, which is still 2.7.

    filepath = utilsDir + 'aclass.log'
    A1 = pickle.load(file(filepath))

All it has worked before updating my python, but now i have an error:

enter image description here

Upvotes: 4

Views: 1537

Answers (1)

Silmathoron
Silmathoron

Reputation: 2001

This is old and the answer will not help the OP, but in case anyone stumbles on this for a code he can modify, this error usually appears when the class pickled in Python 2 is not a new style class, i.e. does not inherit from object.

Upvotes: 2

Related Questions