I am trying to pickle a nested dictionary which is created using: My simplified code goes like this: However it gives error: After I print dictionary it shows: I try to make the dictionary global within that function but the error is the same. I appreciate any solution or insight to this problem. Thanks! Answer pickle records references to functions