title: Unpickle a cloudpickle without cloudpickle installation
body: <p>The default <code>pickle</code> module from the Python standard library does not allow for the serialization of functions with closures, lambdas, or functions in <code>__main__</code> (see <a href="https://docs.python.org/3/library/pickle.html#what-can-be-pickled-and-unpickled" rel="nofollow">here</a>). </p>
  
  <p>I need to pickle an object using some custom functions that will not be importable where they will be unpickled. There are a few other Python object serializers, including <code>dill</code> and <code>cloudpickle</code>, that are capable of doing this. </p>
  
  <p>The <code>cloudpickle</code> <a href="https://github.com/cloudpipe/cloudpickle" rel="nofollow">documentation</a> seems to be saying that even when you pickle using <code>cloudpickle</code>, you can unpickle using the standard <code>pickle</code> module. This is extremely attractive, because I cannot even install packages in the environment where I need to unpickle. </p>
  
  <p>Indeed, the example in the documentation does basically the following:</p>
  
  <h3>Pickle:</h3>
  
  <pre><code>&gt;&gt;&gt; import cloudpickle
  &gt;&gt;&gt; squared = lambda x: x ** 2
  &gt;&gt;&gt; pickled_lambda = cloudpickle.dump(squared, open('pickled_file', 'w'))
  </code></pre>
  
  <h3>Unpickle:</h3>
  
  <pre><code>&gt;&gt;&gt; import pickle
  &gt;&gt;&gt; new_squared = pickle.load(open('pickled_file', 'rb'))
  &gt;&gt;&gt; new_squared(2)
  </code></pre>
  
  <p>But, running that second block in an environment where <code>cloudpickle</code> is not installed, even though it is never imported, yields the error:</p>
  
  <pre><code>"ImportError: No module named cloudpickle.cloudpickle"
  </code></pre>
  
  <p>Probably the most easily reproducible example would be to install <code>cloudpickle</code> for Python2, run the first block, and then try to load in the pickled file with the second block using Python3 (where <code>cloudpickle</code> was not installed).</p>
  
  <p>What is going on here? Why does <code>cloudpickle</code> need to be installed to run the standard <code>pickle</code> load if it is not even called?</p>