title: Compressing a pkl file
body: <p>My requirement is to convert a pkl file to base64 string format so that i can return a json file containing this string along with some other contents.</p>
  
  <pre><code>{                                                                       
      'pkl_file': 'pkl_as_base64_string'                                             
      'content1': 'content1_as_base64_string'
      'content2': 'content2_as_base64_string'                                 
                       .                                                         
                       .                                                   
  }
  </code></pre>
  
  <p>Now i have tried out this code with <a href="https://stackoverflow.com/a/26349372/9316658">https://stackoverflow.com/a/26349372/9316658</a> as the reference       </p>
  
  <pre><code>with open(DIR_PATH + 'd885d7a4bbb742cbb397c2642339e950.pkl', 'rb') as f:
      data = pickle.load(f)
      serialized_str = base64.b64encode(pickle.dumps(data))
      print serialized_str
  </code></pre>
  
  <p>I am getting this when i execute the above code</p>
  
  <pre><code>Traceback (most recent call last):
  File "/home/bhargav/PycharmProjects/Test/export_import.py", line 8, in &lt;module&gt;
      data = pickle.load(f)
  ImportError: No module named ml.model.project_model
  </code></pre>
  
  <p>When i open the pkl file using a text editor, these are the first few lines</p>
  
  <pre><code>(iml.model.project_model
  ProjectModel
  p0
  (dp1
  S'project_predict_pipe'
  p2
  (iml.pipeline.base
  ICVPipeline
  p3
  (dp4
  S'processors'
  p5
  (lp6
  (iml.pi.file.pdf_to_img_pi
  PdfFileConvertPI
  p7
  (dp8
  S'process'
  p9
  Nsba(iml.pi.ocr.file_ocr_pi
  </code></pre>
  
  <p>I am not sure why python is interpreting the text inside the pkl files as python commands ( I am new to python programming and never dealt with pkl files before ). Also, the pkl file is huge in size (1.2 GB). How do i achieve pkl to bas64 conversion in the most effective way possible? Any help is appreciated. TIA </p>