title: Python 3.5 dill pickling/unpickling on different servers: "KeyError: 'ClassType'"
body: <p><strong>See updates at the bottom</strong></p>
  
  <p>--</p>
  
  <p>A similar question was asked here, but never resolved:
  <a href="https://stackoverflow.com/questions/29171310/pickling-and-unpickling-user-defined-class">pickling and unpickling user-defined class</a></p>
  
  <p>I'm working on a project which necessitates pickling user defined classes, and sending them to a remote server where they are unpickled and called. We use the Dill library to accomplish this, and have had a lot of success. </p>
  
  <p>Unfortunately, I've run into an issue I'm having a hard time debugging. I create and pickle a class as follows:</p>
  
  <pre><code>import dill, base64
  import time, random
  
  class periodicSource(object):
      def __call__(self):
          while True:
              time.sleep(0.1)
              yield random.uniform(20,100)
  
  periodic_src = periodicSource()
  a = base64.b64encode(dill.dumps(periodic_src)).decode("ascii")
  print(a)
  </code></pre>
  
  <p>It creates an ascii representation of the dilled class.</p>
  
  <pre><code>gANjZGlsbC5kaWxsCl9jcmVhdGVfdHlwZQpxAChjZGlsbC5kaWxsCl9sb2FkX3R5cGUKcQFYCQAAAENsYXNzVHlwZXEChXEDUnEEWA4AAABwZXJpb2RpY1NvdXJjZXEFaAFYBgAAAG9iamVjdHEGhXEHUnEIhXEJfXEKKFgIAAAAX19jYWxsX19xC2NkaWxsLmRpbGwKX2NyZWF0ZV9mdW5jdGlvbgpxDChoAVgIAAAAQ29kZVR5cGVxDYVxDlJxDyhLAUsASwFLA0tjQyl4IgB0AABqAQBkAQCDAQABdAIAagMAZAIAZAMAgwIAVgFxAwBXZAAAU3EQKE5HP7mZmZmZmZpLFEtkdHERKFgEAAAAdGltZXESWAUAAABzbGVlcHETWAYAAAByYW5kb21xFFgHAAAAdW5pZm9ybXEVdHEWWAQAAABzZWxmcReFcRhYHwAAADxpcHl0aG9uLWlucHV0LTIwLTdhNGU5MDIwYWM2Yz5xGWgLSwdDBgABAwENAXEaKSl0cRtScRx9cR0oWAYAAAByYW5kb21xHmNkaWxsLmRpbGwKX2ltcG9ydF9tb2R1bGUKcR9oFIVxIFJxIVgEAAAAdGltZXEiaB9YBAAAAHRpbWVxI4VxJFJxJXVoC05OfXEmdHEnUnEoWAoAAABfX21vZHVsZV9fcSlYCAAAAF9fbWFpbl9fcSpYBwAAAF9fZG9jX19xK05YDQAAAF9fc2xvdG5hbWVzX19xLF1xLXV0cS5ScS8pgXEwLg==
  </code></pre>
  
  <p>When I go to deserialize it on the other server:</p>
  
  <pre><code>a = 'gANjZGlsbC5kaWxsCl9jcmVhdGVfdHlwZQpxAChjZGlsbC5kaWxsCl9sb2FkX3R5cGUKcQFYCQAAAENsYXNzVHlwZXEChXEDUnEEWA4AAABwZXJpb2RpY1NvdXJjZXEFaAFYBgAAAG9iamVjdHEGhXEHUnEIhXEJfXEKKFgIAAAAX19jYWxsX19xC2NkaWxsLmRpbGwKX2NyZWF0ZV9mdW5jdGlvbgpxDChoAVgIAAAAQ29kZVR5cGVxDYVxDlJxDyhLAUsASwFLA0tjQyl4IgB0AABqAQBkAQCDAQABdAIAagMAZAIAZAMAgwIAVgFxAwBXZAAAU3EQKE5HP7mZmZmZmZpLFEtkdHERKFgEAAAAdGltZXESWAUAAABzbGVlcHETWAYAAAByYW5kb21xFFgHAAAAdW5pZm9ybXEVdHEWWAQAAABzZWxmcReFcRhYHwAAADxpcHl0aG9uLWlucHV0LTIwLTdhNGU5MDIwYWM2Yz5xGWgLSwdDBgABAwENAXEaKSl0cRtScRx9cR0oWAYAAAByYW5kb21xHmNkaWxsLmRpbGwKX2ltcG9ydF9tb2R1bGUKcR9oFIVxIFJxIVgEAAAAdGltZXEiaB9YBAAAAHRpbWVxI4VxJFJxJXVoC05OfXEmdHEnUnEoWAoAAABfX21vZHVsZV9fcSlYCAAAAF9fbWFpbl9fcSpYBwAAAF9fZG9jX19xK05YDQAAAF9fc2xvdG5hbWVzX19xLF1xLXV0cS5ScS8pgXEwLg=='
  a = dill.loads(base64.b64decode(a.encode()))
  print(a)
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>/home/streamsadmin/anaconda3/bin/python /home/streamsadmin/git/streamsx.topology/test/python/topology/deleteme2.py
  
  Traceback (most recent call last):
   File "/home/streamsadmin/git/streamsx.topology/test/python/topology/deleteme2.py", line 40, in &lt;module&gt;
     a = dill.loads(base64.b64decode(a.encode()))
   File "/home/streamsadmin/anaconda3/lib/python3.5/site-packages/dill/dill.py", line 277, in loads
     return load(file)
   File "/home/streamsadmin/anaconda3/lib/python3.5/site-packages/dill/dill.py", line 266, in load
     obj = pik.load()
   File "/home/streamsadmin/anaconda3/lib/python3.5/site-packages/dill/dill.py", line 524, in _load_type
     return _reverse_typemap[name]
  KeyError: 'ClassType'
  </code></pre>
  
  <p>I would expect this if I were using different version of Python on the remote system, but they're the same:</p>
  
  <p>Server 1:</p>
  
  <pre><code>&gt;&gt;&gt; import sys
  &gt;&gt;&gt; sys.version
  '3.5.2 |Anaconda 4.1.1 (64-bit)| (default, Jul  2 2016, 17:53:06) \n[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]'
  </code></pre>
  
  <p>Server 2:</p>
  
  <pre><code>&gt;&gt;&gt; import sys
  &gt;&gt;&gt; sys.version
  '3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul  2 2016, 17:53:06) \n[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]'
  </code></pre>
  
  <p>Additionally, both versions of Dill are 0.2.6. Any ideas how I could debug this?</p>
  
  <p><strong>EDIT: I've think it might be something with my environment.</strong> I'm using Python 3.5, but list the builtin types:</p>
  
  <pre><code>&gt;&gt;&gt; import types
  &gt;&gt;&gt; dir(types)
    ['BuiltinFunctionType',
     'BuiltinMethodType',
     'ClassType',
     'CodeType',
     ...
    ]
  </code></pre>
  
  <p>It seems <em>ClassType</em> is in the output which should <strong>NOT</strong> be the case since <em>ClassType</em> was removed in Python 3.5. This is exceedingly strange. </p>
  
  <p>I'm running on a system that has both Python 2.7 and Python 3.5 installed. Could the 2.7 installation somehow be polluting the 3.5 installation?</p>