{"id":8269,"library":"lazr-uri","title":"lazr-uri","description":"lazr-uri is a self-contained, easily reusable Python library designed for robust parsing, manipulation, and generation of Uniform Resource Identifiers (URIs). The current version is 1.0.7, released on December 9, 2024. The library maintains an infrequent release cadence, with updates typically addressing Python compatibility and internal optimizations.","status":"active","version":"1.0.7","language":"en","source_language":"en","source_url":"https://git.launchpad.net/lazr.uri","tags":["uri","parsing","url","network","manipulation","validation"],"install":[{"cmd":"pip install lazr-uri","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"symbol":"URI","correct":"from lazr.uri import URI"},{"symbol":"find_uris_in_text","correct":"from lazr.uri import find_uris_in_text"}],"quickstart":{"code":"from lazr.uri import URI, find_uris_in_text\n\n# Parsing a URI and accessing its parts\nuri_str = \"https://www.example.com:8080/path/to/resource?query=param&key=value#fragment\"\nuri = URI(uri_str)\n\nprint(f\"Scheme: {uri.scheme}\")\nprint(f\"Host: {uri.host}\")\nprint(f\"Port: {uri.port}\")\nprint(f\"Path: {uri.path}\")\nprint(f\"Query: {uri.query}\")\nprint(f\"Fragment: {uri.fragment}\")\n\n# Manipulating a URI\nnew_uri = uri.replace(scheme='http', port=None)\nprint(f\"Modified URI: {new_uri}\")\n\n# Finding URIs within a text block\ntext_with_uris = \"Visit our site at http://example.org or email us at mailto:support@example.net.\"\nfound_uris = list(find_uris_in_text(text_with_uris))\nfor found_uri in found_uris:\n    print(f\"Found URI: {found_uri}\")","lang":"python","description":"Demonstrates how to parse a URI, access its components, modify it, and extract multiple URIs from a block of text."},"warnings":[{"fix":"Upgrade your Python environment to version 3.8 or higher. If unable to upgrade Python, use `lazr-uri<1.0.7`.","message":"Version 1.0.7 dropped support for Python versions 3.7 and below.","severity":"breaking","affected_versions":">=1.0.7"},{"fix":"Upgrade to `lazr-uri` version 1.0.6 or newer to benefit from the adjusted versioning strategy that avoids `pkg_resources` for better performance.","message":"Prior to version 1.0.6, `lazr.uri`'s versioning strategy imported `pkg_resources`, which could lead to significant performance overhead in large Python environments during startup.","severity":"gotcha","affected_versions":"<1.0.6"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure `lazr-uri` is correctly installed and up-to-date with `pip install --upgrade lazr-uri`. Verify no other packages are conflicting with the `lazr.uri` namespace.","cause":"This usually indicates an outdated version of `lazr-uri` or an issue with the Python environment where a module named `lazr.uri` exists but does not contain the `URI` class, or a namespace conflict.","error":"ImportError: cannot import name 'URI' from 'lazr.uri' (...)"},{"fix":"Always check if URI components like `uri.port` are `None` before attempting operations on them. Example: `if uri.port is not None: print(uri.port)`.","cause":"When a URI string does not explicitly include a port, the 'port' attribute of the `URI` object will be `None`, leading to an `AttributeError` if you try to access methods or properties directly on it without checking if it's `None`.","error":"AttributeError: 'URI' object has no attribute 'port' (when expecting a port from a URI without one)"}]}