Joblib is a set of tools for lightweight pipelining in Python, providing transparent disk-caching of functions and easy parallel computing. Current version: 1.5.3. Release cadence: Regular updates with recent releases in 2025 and 2026.
Install & Compatibility
Where this runs
tested against v1.5.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.925 runs
installs and imports cleanly · install 0.0s · import 0.493s · 19.9MB
glibcpy 3.10–3.925 runs
installs and imports cleanly · install 1.7s · import 0.423s · 20MB
18MB installed
● package 18MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Memory
✓ from joblib import Memory
Ensure correct import path for Memory class
Example of using Joblib's Memory class for caching a function's output.
from joblib import Memory
# Set up a cache directory
location = 'your_cache_dir'
mem = Memory(location, verbose=1)
# Define a function to cache
import numpy as np
def square(x):
return np.square(x)
# Cache the function
cached_square = mem.cache(square)
# Use the cached function
result = cached_square(np.array([1, 2, 3]))
print(result)
Errors
Common errors & fixes
ImportError: cannot import name 'joblib' from 'sklearn.externals'
This error occurs in newer versions of scikit-learn (0.21.0 and later) because `joblib` was decoupled from `sklearn.externals` and is now an independent package.
fixInstall `joblib` separately if you haven't already (`pip install joblib`) and update your import statement to `import joblib` instead of `from sklearn.externals import joblib`.
FileNotFoundError: [Errno 2] No such file or directory: 'your_model.joblib'
`joblib.load()` cannot find the specified file because the file path is incorrect, the file does not exist at that location, or the script's current working directory is not what is expected.
fixEnsure the file path provided to `joblib.load()` is correct and that the file exists. Use absolute paths, `os.path.join` for robust path construction, or adjust the script's working directory.
AttributeError: Can't get attribute 'your_function_or_class' on <module '__main__' (built-in)>
This error typically arises when attempting to load a `joblib` file that contains references to custom classes or functions defined within the `__main__` module of the script that saved the object, and these definitions are not available or properly imported in the environment where the file is being loaded. This often happens when functions or classes are defined interactively or not in a proper module.
fixEnsure that any custom classes or functions referenced in the saved object are defined in a separate Python module (e.g., `my_module.py`) and that this module is imported in both the saving and loading scripts. The module containing the definitions must be importable in the loading environment.
ImportError: [joblib] Attempting to do parallel computing without protecting your import on a system that does not support forking.
When using `joblib.Parallel` on systems that do not support forking (like Windows), or when running scripts directly without the necessary protection, the main script can be recursively re-imported, leading to this error.
fixWrap the main execution logic that uses `joblib.Parallel` within an `if __name__ == '__main__':` block.
BrokenProcessPool: A task has failed to un-serialize. Please ensure that the arguments of the function are all picklable.
This error occurs during parallel processing when the objects (arguments or return values) being sent to or from worker processes cannot be serialized (pickled). This can happen due to non-picklable object types, version mismatches between `joblib` or Python itself, or issues with third-party libraries.
fixEnsure all objects passed to `delayed` functions and returned by them are picklable. Check for version compatibility between `joblib`, Python, and any other libraries involved. Sometimes, updating `cloudpickle` (a dependency of `joblib`) or ensuring consistent Python versions can resolve this.
Audit
Dependencies
numpyoptionalOptional dependency for array manipulation