{"id":392,"library":"dill","title":"dill","description":"dill extends Python's pickle module for serializing and deserializing Python objects, supporting a wide range of built-in types. The current version is 0.4.1, released on January 19, 2026, with active development and regular updates.","status":"active","version":"0.4.1","language":"python","source_language":"en","source_url":"https://github.com/uqfoundation/dill","tags":["serialization","pickle","Python"],"install":[{"cmd":"pip install dill","lang":"bash","label":"Install dill"}],"dependencies":[{"reason":"Required for installation","package":"setuptools","optional":false}],"imports":[{"note":"dill is imported directly as 'dill'","symbol":"dill","correct":"import dill"}],"quickstart":{"code":"import dill\n\n# Serialize an object\nobj = {'key': 'value'}\nwith open('obj.pkl', 'wb') as f:\n    dill.dump(obj, f)\n\n# Deserialize the object\nwith open('obj.pkl', 'rb') as f:\n    loaded_obj = dill.load(f)\nprint(loaded_obj)","lang":"python","description":"A basic example demonstrating how to serialize and deserialize an object using dill."},"warnings":[{"fix":"Update function calls to 'dump_module()' with the new parameter names.","message":"Function 'dump_session()' was renamed to 'dump_module()' in version 0.3.6. Parameters 'main' and 'byref' were renamed to 'module' and 'refimported', respectively.","severity":"breaking","affected_versions":"0.3.6"},{"fix":"Avoid using these settings with 'dump_module()'.","message":"The 'dill.settings['byref']' and 'dill.settings['recurse']' settings do not apply to the 'dump_module()' function.","severity":"deprecated","affected_versions":"0.3.6"}],"env_vars":null,"last_verified":"2026-05-12T13:29:24.878Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"Downgrade `dill` to a version compatible with the dependent library. For example, `pip install dill==0.3.5.1` or `pip install dill<0.3.6` if the issue is with `log` or `PY3` (check the dependent library's requirements).","cause":"This error typically occurs due to an incompatibility or version mismatch between the installed `dill` library and another dependent package (e.g., `datasets`, `nlp`) that expects a specific internal attribute of `dill` which has been removed or renamed in a newer version.","error":"AttributeError: module 'dill._dill' has no attribute 'log'"},{"fix":"Install the `dill` package using pip: `pip install dill`. If a local script is named `dill.py`, rename it to avoid conflicting with the library import.","cause":"The `dill` library is not installed in the Python environment where the code is being executed, or there is a naming conflict where a local script is named `dill.py`.","error":"ModuleNotFoundError: No module named 'dill'"},{"fix":"Ensure you are explicitly importing and using `dill` for serialization and deserialization (e.g., `import dill; dill.dump(obj, file)`). For classes defined in `__main__` or when pickling modules, setting `dill.settings['recurse'] = True` before pickling can help `dill` trace and serialize global objects more comprehensively.","cause":"While `dill` enhances Python's `pickle`, complex objects, especially dynamically created classes or objects defined directly in the `__main__` module, can still sometimes cause `PicklingError` if their exact context or definition isn't correctly preserved or recreated during deserialization, particularly across different environments or when `dill` is used with default `pickle`-like behavior for certain types.","error":"_pickle.PicklingError: Can't pickle <class '__main__.MyClass'>: it's not the same object as __main__.MyClass"},{"fix":"Ensure that the `dill.dump()` or `dill.dump_session()` operation completes successfully, and that the file buffer is flushed (e.g., `f.flush(); os.fsync(f.fileno())` for file objects) if writing to disk. Verify there is sufficient disk space when creating the pickled file, and regenerate the file if it is corrupted.","cause":"This error indicates that the `.pkl` file being loaded is incomplete or corrupted, most often because the file writing process (e.g., from `dill.dump()` or `dill.dump_session()`) was interrupted or failed to write all data to disk.","error":"UnpicklingError: pickle data was truncated"},{"fix":"Correct the function call to use the appropriate `dill` method, such as `dill.load(file)` or `dill.dumps(obj)`. If the error context involves `pprint`, ensure it's imported correctly, e.g., `from pprint import pprint` if `pprint` is intended to be used as a function.","cause":"This error occurs when the `dill` module itself is mistakenly called as a function (e.g., `dill(...)`) instead of invoking its specific functions (like `dill.load()` or `dill.dumps()`). It can also rarely indicate an incorrect import of another module like `pprint` in older contexts.","error":"TypeError: 'module' object is not callable"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":80,"quickstart_tag":"verified","pypi_latest":null,"cli_name":null,"install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.14,"mem_mb":7,"disk_size":"18.6M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.1,"mem_mb":7,"disk_size":"19M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.23,"mem_mb":7.5,"disk_size":"20.6M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.2,"mem_mb":7.5,"disk_size":"21M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.2,"mem_mb":7.5,"disk_size":"12.5M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.2,"mem_mb":7.6,"disk_size":"13M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.19,"mem_mb":7.8,"disk_size":"12.1M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.2,"mem_mb":7.7,"disk_size":"13M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.14,"mem_mb":6.8,"disk_size":"18.1M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.12,"mem_mb":6.8,"disk_size":"19M"}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"verified","tag_description":"quickstart runs on critical runtimes, recently tested","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}