Error reading "pickle" file, no module named 'Data'

11,130

The program that created the pickle file did import Data and there are references to that module inside the pickled object. The program that loads the pickled object needs to be able to import that module to resolve those references. Either put the location of Data.py on your PYTHONPATH (or add the location to sys.path), or copy the module to where your program can find it.

Share:
11,130

Related videos on Youtube

Bolat Tleubayev
Author by

Bolat Tleubayev

Artificial Intelligence MSc from KU Leuven. Interested in Machine/Deep Learning and Computer Vision

Updated on June 04, 2022

Comments

  • Bolat Tleubayev
    Bolat Tleubayev about 2 years

    I tried to read pickle file using Anaconda Navigator and have the following script.

    import pickle
    import sys, os 
    
    with open('pickle1', 'rb') as fp:
        data_new = pickle.load(fp)
    

    After running the window I get the following error window.

    ---------------------------------------------------------------------------
    ModuleNotFoundError                       Traceback (most recent call last)
    <ipython-input-4-047bee0f1247> in <module>()
          3 
          4 with open('pickle1', 'rb') as fp:
    ----> 5     data_new = pickle.load(fp)
    
    ModuleNotFoundError: No module named 'Data'
    

    Can you please help me fix this issue? I tried to rename file to *.pkl, and *.csv formats, but it did not help. Original data file has no extension of its own.

  • Bolat Tleubayev
    Bolat Tleubayev over 5 years
    Thanks! I work on my colleague's code, so I didn't know about Data.py file