formachines / errata

Errata / PyPI / joblib

joblib.externals.cloudpickle removed in joblib 1.6.0

In our sandbox runs up to 2026-10-27, gemini-3.8-flash and gpt-6.1-sol wrote from joblib.externals import cloudpickle for joblib. It fails on 1.6.0 with ImportError (changed between 1.5.3 and 1.6.0). Use import cloudpickle instead.

What to do
replace the line
Output
same on one example
Patch
applies word for word
Auto-apply
allowed
Seen in
2 models
Worked / failed
3 / 0
Last verified
2026-10-27

What to do

Replace the old line with the new one; the rest of the code can stay.

Automatic application: allowed — proof.equivalent is true and the patch applies word for word. Automatic application is allowed only when proof.equivalent is true and proof.applicability.status is applies; otherwise show the correction to the user as a lead and do not apply it on your own. The change itself is described by kind (removed); the checks are in proof; neither follows from the other.

How to tell this applies to your code

Old and new code

from joblib.externals import cloudpickle
import cloudpickle

Error on 1.6.0:

ImportError: cannot import name 'cloudpickle' from 'joblib.externals' (/usr/local/lib/python3.11/site-packages/joblib/externals/__init__.py)
Sandbox proof
Scriptjoblib versionResult
Code the models wrote1.5.3works
Code the models wrote1.6.0fails: ImportError
Verified example below1.6.0works
Output of the verified example1.6.0same as the original's on 1.5.3 (observed stdout of one example; not a proof of equivalent behaviour)
Patch applied word for word to the example1.6.0applied word for word, the patch parses, runs and prints what the verified example prints

Verified example for joblib 1.6.0

import pickle
import cloudpickle


def main():
    # 1. Define a lambda and a locally defined closure
    f_lambda = lambda x, y: x**2 + y

    def make_closure(multiplier, offset):
        def inner(val):
            return val * multiplier + offset

        return inner

    f_closure = make_closure(multiplier=10, offset=7)

    # 2. Serialize both to bytes using joblib's bundled cloudpickle
    lambda_bytes = cloudpickle.dumps(f_lambda)
    closure_bytes = cloudpickle.dumps(f_closure)

    # 3. Load them back using the standard library's pickle module
    restored_lambda = pickle.loads(lambda_bytes)
    restored_closure = pickle.loads(closure_bytes)

    # 4. Print results of calling each restored function on sample inputs
    print("Testing restored lambda:")
    print("restored_lambda(3, 5):", restored_lambda(3, 5))
    print("restored_lambda(4, -2):", restored_lambda(4, -2))

    print("\nTesting restored closure:")
    print("restored_closure(2):", restored_closure(2))
    print("restored_closure(5):", restored_closure(5))


if __name__ == "__main__":
    main()

Source

Unvendor cloudpickle to more quickly benefit from maintenance releases of cloudpickle

Release notes · Seen in: gemini-3.8-flash, gpt-6.1-sol · First seen 2026-10-26 · Last verified 2026-10-27 · All corrections for joblib

For agents