Fixed: AttributeError: 'code' object has no attribute 'co_lnotab'
On Python 3.15, Dataset.map(..., num_proc=2) from Hugging Face's datasets library failed with AttributeError: 'code' object has no attribute 'co_lnotab'. The error comes from dill, which datasets uses to send your function to its worker processes: Python 3.15 removed co_lnotab, and the dill version datasets allows still reads it. Moving the project to Python 3.14 fixed it.
What I Was Doing
I made a project with uv on Python 3.15.2, the newest Python, and added the datasets library:
uv init --python 3.15 datasets-demo
cd datasets-demo
uv add datasets
uv add installed datasets 5.2.0, with dill 0.4.1 and multiprocess 0.70.19 among its dependencies. The script turns every word in a small dataset into capitals, with two processes working in parallel:
from datasets import Dataset
def shout(row):
return {"text": row["text"].upper()}
if __name__ == "__main__":
words = Dataset.from_dict({"text": ["hello", "world"]})
shouted = words.map(shout, num_proc=2)
print(shouted["text"])
num_proc=2 asks map to split the work between two processes. The if __name__ == "__main__": line is there because those processes start by loading this file again.
uv run main.py
What I Expected
Column(['HELLO', 'WORLD'])
What I Got
A long traceback, ending in:
obj.co_lnotab, # for < python 3.10 [not counted in args]
^^^^^^^^^^^^^
AttributeError: 'code' object has no attribute 'co_lnotab'. Did you mean '.co_linetable' instead of '.co_lnotab'?
when serializing tuple item 0
when serializing function reconstructor arguments
when serializing dict item 'function'
when serializing tuple item 2
when serializing tuple item 3

The when serializing ... dict item 'function' lines say it failed while packing up my shout function, in dill/_dill.py, not in my code or in datasets.
What I Checked
1. Without num_proc, it works
I removed num_proc=2 from the map call and ran it again:
uv run main.py
Map: 100%|████████████████████████████████████████████████████| 2/2 [00:00<00:00, 593.13 examples/s]
Column(['HELLO', 'WORLD'])
![The terminal after running main.py without num_proc: a Map progress bar at 100 percent, then Column(['HELLO', 'WORLD']).](https://strdewiridedevblogsprod.blob.core.windows.net/images/blog/ai/hugging-face/datasets/fixes/2026/ds-lnotab-02-single.webp)
So map itself works on 3.15. Only sending the function to other processes fails. (I put num_proc=2 back for the rest of this post.)
2. dill alone fails the same way
The traceback ended in dill, so I asked dill to pack the smallest function there is:
uv run python -c "import dill; dill.dumps(lambda: None)"
^^^^^^^^^^^^^
AttributeError: 'code' object has no attribute 'co_lnotab'. Did you mean '.co_linetable' instead of '.co_lnotab'?
when serializing tuple item 0
when serializing function reconstructor arguments

The same error, without datasets involved at all. The versions in play:
uv run python -c "import sys, datasets, dill; print(sys.version.split()[0], datasets.__version__, dill.__version__)"
3.15.2 5.2.0 0.4.1
3. What the documentation and the packages say
- Python 3.15 removed the attribute. What's New in Python 3.15 lists: "Removed codeobject.co_lnotab from types.CodeType, deprecated since Python 3.12 by PEP 626."
- datasets doesn't list Python 3.15 yet. Its installation guide says "Datasets is tested on Python 3.10+", and datasets 5.2.0's package lists Python 3.10 to 3.14 as supported versions.
- datasets pins dill below 0.4.2. Its
setup.pyrequiresdill>=0.3.0,<0.4.2andmultiprocess<0.70.20. dill 0.4.1 is the newest release, and it still readsco_lnotab.
Why It Happens
datasets hashes your function itself, with code that was already updated for newer Pythons, which is why a single-process map works. With num_proc, it hands the function to multiprocess, which sends it to the worker processes using dill's own pickler, and dill 0.4.1 reads obj.co_lnotab, which no longer exists in Python 3.15.
dill has already changed this on its development branch, but that change isn't in a release yet, and datasets' dill<0.4.2 pin would keep the next release out anyway. I reported it to datasets as issue #9312, so the pins can move when dill and multiprocess release their Python 3.15 support.
The Fix
Use Python 3.14, the newest version datasets supports. My first try was to pin it directly:
uv python pin 3.14
error: The requested Python version `3.14` is incompatible with the project `requires-python` value of `>=3.15`.

uv refused: uv init --python 3.15 had written requires-python = ">=3.15" into pyproject.toml. So first change that line, to say the project needs 3.14 and doesn't work on 3.15 yet:
requires-python = ">=3.14,<3.15"
The <3.15 keeps anyone who installs the project off Python 3.15 until it works there. Then pin again:
uv python pin 3.14
Updated `.python-version` from `3.15` -> `3.14`

How to Change a uv Project's Python Version with uv python pin explains both commands in detail.
After the Fix
uv run main.py
Using CPython 3.14.10
Removed virtual environment at: .venv
Creating virtual environment at: .venv
warning: Resolving despite existing lockfile due to fork markers being disjoint with `requires-python`: `python_full_version >= '3.15'` vs `python_full_version == '3.14.*'`
Built datasets-demo @ file:///Users/you/source/datasets-demo
Installed 25 packages in 110ms
Map (num_proc=2): 100%|████████████████████████████████████████| 2/2 [00:00<00:00, 16.45 examples/s]
Column(['HELLO', 'WORLD'])
![The terminal after the fix: uv used CPython 3.14.10, recreated .venv and installed 25 packages, the Map (num_proc=2) bar reached 100 percent, and the script printed Column(['HELLO', 'WORLD']).](https://strdewiridedevblogsprod.blob.core.windows.net/images/blog/ai/hugging-face/datasets/fixes/2026/ds-lnotab-06-fixed.webp)
uv saw the new Python version, rebuilt the environment on 3.14.10, and map ran with two processes. Its first line is a warning, not an error: the lock file had been made for >=3.15, so uv worked out the packages again for 3.14. The versions now:
uv run python -c "import sys, datasets, dill; print(sys.version.split()[0], datasets.__version__, dill.__version__)"
3.14.10 5.2.0 0.4.1
Same datasets, same dill; only Python changed. The commands work unchanged in PowerShell.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
Pinning 3.14 before changing requires-python | error: The requested Python version `3.14` is incompatible with the project `requires-python` value of `>=3.15`. | Change requires-python first |
Removing num_proc to make the error go away | map works, but on one process: slower on big datasets, and the project still sits on a Python its libraries don't support | Move to Python 3.14 |
| Installing a newer dill by hand | datasets requires dill<0.4.2, so uv won't install a version outside that range | Wait for datasets to allow it; use 3.14 until then |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
AttributeError: 'code' object has no attribute 'co_lnotab' from dill/_dill.py | Python 3.15 with dill 0.4.1 | Use Python 3.14 |
| The same error from another library that uses dill | The same dill version | The same fix, or that library's update |
FAQ
When will Python 3.15 work?
When dill and multiprocess release their Python 3.15 changes, and datasets raises its version limits to allow them. Issue #9312 tracks it on the datasets side.
Do I lose anything with Python 3.14?
Only Python 3.15's new features. Everything in this post's stack supports 3.14.
Conclusion
AttributeError: 'code' object has no attribute 'co_lnotab' came from dill 0.4.1, which datasets 5.2.0 uses to send functions to worker processes, on Python 3.15, which removed co_lnotab. With requires-python = ">=3.14,<3.15" and uv python pin 3.14, the same code ran on Python 3.14.10 with two processes.
Additional Resources
- What's New in Python 3.15 — the removal of
co_lnotab. - datasets installation — the supported Python versions.
- Dataset.map —
num_procand multiprocessing. - huggingface/datasets issue #9312 — my report of this problem.
