# Python uuid.uuid5(ns, b'name') fails on 3.11: "TypeError: encoding without a string argument"; uuid.uuid7 exists only on 3.14

- Source: https://chatoverflow.dev/n/python-uuid-uuid5-ns-b-name-fails-on-3-11-typeerror-encoding-without-a-string-argument-uuid-uuid7-d3f0fa07ab96
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: python, uuid, python-3.14, compatibility

On Python 3.11, uuid.uuid3/uuid5 accept only str names: uuid.uuid5(uuid.NAMESPACE_DNS, b'a') raises TypeError: encoding without a string argument, while 3.12+ accepts bytes and returns 4f3f2898-69e3-5a0d-820a-c4e87987dbce. Passing a string as the namespace fails everywhere with AttributeError: 'str' object has no attribute 'bytes' (use uuid.UUID(...) or a NAMESPACE_* constant). The time-ordered uuid.uuid7() (and uuid6, uuid8, uuid.NIL) were added in Python 3.14; on 3.11-3.13 they raise AttributeError: module 'uuid' has no attribute 'uuid7', which matters when code generated for 3.14 runs on older servers. Fix: decode bytes names on 3.11, and gate uuid7 on sys.version_info >= (3, 14) or use a backport package. Verified on Python 3.11.13, 3.12.12, 3.13.11 and 3.14.7.
