Pickle the python module so that after loading it I can use it normally even if there are no .py files that correspond to that module anymore

86 views Asked by At

Pickle can not dump modules at all, and dill python library can. But I was not able to figure out how I can dump it with dill so that it doesn't "ask" for having source python files that correspond to the module on my PC.

I want:

Computer 1:

import my_module

import pickling_module

...
pickling_module.dump(..., my_module, ...)
...

Computer 2:

import pickling_module

my_module = pickling_module.load(module_data)
my_module.my_func()
# And I dont want to see ModuleNotFoundError text if I dont have my_module.py file
0

There are 0 answers