{"id":9384,"library":"uuid7-standard","title":"UUID7 Standard (pypi: uuid7-standard)","description":"This library provides a Python implementation for generating and manipulating UUIDs adhering to the final UUID version 7 standard, ensuring time-ordered identifiers. It explicitly distinguishes itself from the older `uuid7` package on PyPI, which was based on an earlier draft of the standard. The current version is 1.1.0, and it follows a release cadence driven by bug fixes and minor improvements.","status":"active","version":"1.1.0","language":"en","source_language":"en","source_url":"https://github.com/LeoVasanko/uuid7-standard","tags":["uuid","identifiers","rfc-4122","uuidv7","time-based","python3.8+"],"install":[{"cmd":"pip install uuid7-standard","lang":"bash","label":"Install uuid7-standard"}],"dependencies":[],"imports":[{"note":"The `import uuid7` statement imports a *different* package (`uuid7`) based on an older draft of the UUIDv7 standard. For the final standard, ensure you install `uuid7-standard` and import from `uuid7_standard`.","wrong":"import uuid7","symbol":"generate_uuid","correct":"from uuid7_standard import generate_uuid"},{"note":"Similar to `generate_uuid`, importing `UUID7` from the `uuid7` package will use a different implementation based on an older draft.","wrong":"from uuid7 import UUID7","symbol":"UUID7","correct":"from uuid7_standard import UUID7"}],"quickstart":{"code":"from uuid7_standard import generate_uuid, UUID7\n\n# Generate a UUIDv7 object\nnew_uuid = generate_uuid()\nprint(f\"Generated UUIDv7 object: {new_uuid}\")\nprint(f\"Type: {type(new_uuid)}\")\nprint(f\"UUIDv7 as string: {str(new_uuid)}\")\n\n# You can also parse a UUIDv7 string into a UUID7 object\n# Example valid UUIDv7 string (replace with your actual UUID if needed)\nuuid_str = str(new_uuid) # Or use a known valid UUIDv7 string\ntry:\n    parsed_uuid = UUID7(uuid_str)\n    print(f\"Parsed UUIDv7 object: {parsed_uuid}\")\n    print(f\"Timestamp of parsed UUID: {parsed_uuid.datetime}\")\nexcept ValueError as e:\n    print(f\"Error parsing UUID: {e}\")","lang":"python","description":"This quickstart demonstrates how to generate a new UUIDv7 using `generate_uuid()` and how to parse an existing UUIDv7 string back into a `UUID7` object."},"warnings":[{"fix":"Always explicitly install `pip install uuid7-standard` and import from `uuid7_standard` (e.g., `from uuid7_standard import generate_uuid`) to ensure you are using the final standard's implementation. Do not use `import uuid7` if you intend to use this library.","message":"There is a significant potential for confusion with the `uuid7` package on PyPI. The `uuid7` package implements an older draft of the UUIDv7 standard, which is different from the final standard implemented by `uuid7-standard`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"To obtain the UUID string, explicitly cast the `UUID7` object to `str()` (e.g., `str(generate_uuid())`) or use its `.hex` attribute (e.g., `generate_uuid().hex`).","message":"The `generate_uuid()` function returns a `UUID7` object, which provides methods for accessing its components (like `datetime`). It does not directly return a string. If a string representation is immediately needed, explicit conversion is required.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"If you intend to use the `uuid7-standard` library, ensure your imports are `from uuid7_standard import ...`. If you genuinely meant to use the other package, install it via `pip install uuid7`.","cause":"This error typically occurs when you've installed `uuid7-standard` but are attempting to import from `uuid7` (e.g., `import uuid7`). The `uuid7` package is a separate, distinct library.","error":"ModuleNotFoundError: No module named 'uuid7'"},{"fix":"Use the correct API for `uuid7-standard`. The main generation function is `generate_uuid()` (e.g., `from uuid7_standard import generate_uuid; new_uuid = generate_uuid()`).","cause":"You are likely trying to call a function or attribute (like `uuid7.uuid7()` or `uuid7.generate()`) that exists in the *other* `uuid7` package, but not in `uuid7_standard`.","error":"AttributeError: module 'uuid7_standard' has no attribute 'uuid7'"},{"fix":"Ensure the input string conforms to the UUID standard, which is a 32-character hexadecimal string, optionally separated by hyphens (e.g., `UUID7('018d9f0a-b2c3-7a4e-9f0d-1e2f3g4h5i6j')`).","cause":"This error occurs when attempting to create a `UUID7` object from a string that is not a valid UUID format (e.g., incorrect length, invalid characters, or missing hyphens).","error":"ValueError: bad badly formed hexadecimal UUID string"}]}