{"id":356,"library":"joblib","title":"Joblib: Lightweight pipelining with Python functions","description":"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.","status":"active","version":"1.5.3","language":"python","source_language":"en","source_url":"https://github.com/joblib/joblib","tags":["parallel computing","caching","pipelines","Python"],"install":[{"cmd":"pip install joblib","lang":"bash","label":"Install Joblib"}],"dependencies":[{"reason":"Optional dependency for array manipulation","package":"numpy","optional":true}],"imports":[{"note":"Ensure correct import path for Memory class","symbol":"Memory","correct":"from joblib import Memory"}],"quickstart":{"code":"from joblib import Memory\n\n# Set up a cache directory\nlocation = 'your_cache_dir'\nmem = Memory(location, verbose=1)\n\n# Define a function to cache\nimport numpy as np\n\ndef square(x):\n    return np.square(x)\n\n# Cache the function\ncached_square = mem.cache(square)\n\n# Use the cached function\nresult = cached_square(np.array([1, 2, 3]))\nprint(result)","lang":"python","description":"Example of using Joblib's Memory class for caching a function's output."},"warnings":[{"fix":"Review and update cache directory configurations to align with new Memory class behavior.","message":"Joblib 1.5.3 introduces changes to the Memory class that may affect existing cache directories.","severity":"breaking","affected_versions":"1.5.3"},{"fix":"Avoid loading objects from untrusted sources to maintain security.","message":"Using joblib.load() on untrusted sources can execute arbitrary code, posing security risks.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Install the 'numpy' package using pip: `pip install numpy`.","message":"ModuleNotFoundError: No module named 'numpy' indicates that the 'numpy' package is not installed in the environment.","severity":"breaking","affected_versions":"All versions"},{"fix":"Ensure numpy is installed in the environment by adding 'pip install numpy' to the setup process or requirements.","message":"ModuleNotFoundError: No module named 'numpy'. The numpy package is missing from the environment, causing script execution to fail.","severity":"breaking","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-05-12T13:15:35.867Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"Install `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`.","cause":"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.","error":"ImportError: cannot import name 'joblib' from 'sklearn.externals'"},{"fix":"Ensure 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.","cause":"`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.","error":"FileNotFoundError: [Errno 2] No such file or directory: 'your_model.joblib'"},{"fix":"Ensure 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.","cause":"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.","error":"AttributeError: Can't get attribute 'your_function_or_class' on <module '__main__' (built-in)>"},{"fix":"Wrap the main execution logic that uses `joblib.Parallel` within an `if __name__ == '__main__':` block.","cause":"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.","error":"ImportError: [joblib] Attempting to do parallel computing without protecting your import on a system that does not support forking."},{"fix":"Ensure 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.","cause":"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.","error":"BrokenProcessPool: A task has failed to un-serialize. Please ensure that the arguments of the function are all picklable."}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":0,"quickstart_tag":"stale","pypi_latest":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.34,"mem_mb":14.4,"disk_size":"19.9M"},{"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.23,"mem_mb":14.4,"disk_size":"20M"},{"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.46,"mem_mb":15.9,"disk_size":"22.2M"},{"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.39,"mem_mb":15.9,"disk_size":"23M"},{"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.7,"mem_mb":16.3,"disk_size":"14.0M"},{"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.63,"mem_mb":16.3,"disk_size":"14M"},{"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.71,"mem_mb":16.2,"disk_size":"13.6M"},{"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.64,"mem_mb":16.2,"disk_size":"14M"},{"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.33,"mem_mb":14.1,"disk_size":"19.4M"},{"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.28,"mem_mb":14.1,"disk_size":"20M"}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"stale","tag_description":"widespread failures or data too old to trust","results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}}