{"id":290,"library":"zipp","title":"zipp","description":"zipp is the official backport of the pathlib-compatible zipfile.Path object from the Python standard library. It provides a Traversable/pathlib-like interface for navigating and reading ZIP archives (zipp.Path), with new features introduced here first and later merged into CPython. Current version is 3.23.0, released June 2025, with a very active cadence of roughly one release per month maintained by Jason R. Coombs (jaraco).","status":"active","version":"3.23.0","language":"python","source_language":"en","source_url":"https://github.com/jaraco/zipp","tags":["zip","pathlib","backport","stdlib","filesystem","archives","importlib"],"install":[{"cmd":"pip install zipp","lang":"bash","label":"Latest stable"}],"dependencies":[],"imports":[{"note":"Use zipp.Path, not zipfile.Path — zipp always carries the latest features ahead of the stdlib backport.","wrong":"from zipfile import Path","symbol":"Path","correct":"import zipp; path = zipp.Path('archive.zip')"},{"note":"The zipfile compatibility overlay submodule; available since zipp 3.19. Do not attempt to import it on older versions.","symbol":"zipp.compat.overlay","correct":"import zipp.compat.overlay"}],"quickstart":{"code":"import io\nimport zipfile\nimport zipp\n\n# Build an in-memory zip\ndata = io.BytesIO()\nwith zipfile.ZipFile(data, 'w') as zf:\n    zf.writestr('hello.txt', 'Hello, zipp!')\n    zf.writestr('sub/world.txt', 'World!')\n    zf.filename = 'example.zip'\n\n# Navigate with zipp.Path (pathlib-style)\nroot = zipp.Path(data)\nfor item in root.iterdir():\n    print(item.name, item.is_file())\n\n# Read a nested file\nfile_path = root / 'hello.txt'\nprint(file_path.read_text())  # 'Hello, zipp!'\n\n# Glob support\nfor txt in root.glob('**/*.txt'):\n    print(txt)","lang":"python","description":"Create an in-memory ZIP, wrap it with zipp.Path, iterate entries, read file content, and glob for files — all using a pathlib-style API."},"warnings":[{"fix":"Pass mode='rb' explicitly for binary reads. Remove any positional pwd argument; keyword args still pass through to io.TextIOWrapper.","message":"zipp.Path.open() changed to text mode by default and dropped positional pwd and force_zip64 parameters.","severity":"breaking","affected_versions":"<3.2"},{"fix":"Replace joinpath(add='sub/path') with joinpath('sub/path') or the / operator (root / 'sub' / 'path').","message":"Path.joinpath() dropped the 'add' keyword argument; it now only accepts arbitrary positional path segments.","severity":"breaking","affected_versions":"<3.6"},{"fix":"Pin to zipp<3.20 if you must support Python 3.8. For Python 3.7, pin to zipp<3.5.","message":"Requires Python >=3.9 as of recent releases. Older zipp releases supported Python 3.6/3.7/3.8 but those branches are no longer maintained.","severity":"breaking","affected_versions":">=3.20"},{"fix":"Use path.name (strips the slash) rather than str(path) when comparing directory names.","message":"Directory entries from iterdir() always end with a trailing slash in their string representation. Comparing path names with string equality will fail unless you strip the slash.","severity":"gotcha","affected_versions":"all"},{"fix":"Do not rely on the original ZipFile object type after wrapping it in zipp.Path; use the zipp.Path interface exclusively for all navigation.","message":"Passing a ZipFile object to zipp.Path mutates the ZipFile in place (converts it to a CompleteDirs subclass). The caller's reference is affected. This is by design to prevent double-close bugs.","severity":"gotcha","affected_versions":">=3.3"},{"fix":"Filter results with item.is_file() when you want only files: [p for p in root.glob('**/*.txt') if p.is_file()].","message":"Path.glob('**') previously did not match directories; since 3.20 it does. Code that relied on glob returning only files may now receive unexpected directory entries.","severity":"gotcha","affected_versions":">=3.20"},{"fix":"Declare a loose lower bound (zipp>=3.9) rather than an exact pin unless you have a specific compatibility reason.","message":"zipp is commonly pulled in as a transitive dependency (e.g. by importlib-metadata, pip, pytest). Pinning it too tightly in lock files can block upgrades of those tools.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-12T12:52:29.753Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"pip install zipp","cause":"The 'zipp' package has not been installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'zipp'"},{"fix":"from zipp import Path","cause":"The 'Path' class in the 'zipp' package is named with an uppercase 'P'.","error":"ImportError: cannot import name 'path' from 'zipp'"},{"fix":"Ensure 'zipp.Path' is initialized with a path to a valid ZIP archive file (e.g., 'my_archive.zip') and then navigate inside it. For regular filesystem paths, use 'pathlib.Path' instead.","cause":"The 'zipp.Path' object was initialized with a path to a file that is not a valid ZIP archive. 'zipp.Path' is designed to navigate *within* a ZIP file, not to represent regular filesystem paths.","error":"zipfile.BadZipFile: File is not a zip file"},{"fix":"Navigate to a specific file within the directory (e.g., 'path / 'filename.txt'') before calling read methods.","cause":"A method like 'read_text()' or 'read_bytes()' was called on a 'zipp.Path' object that points to a directory within the ZIP archive, not an actual file.","error":"IsADirectoryError: 'directory_name'"}],"ecosystem":"pypi","meta_description":null,"install_score":0,"install_tag":"stale","quickstart_score":80,"quickstart_tag":"verified","pypi_latest":null,"install_checks":{"last_tested":"2026-05-12","tag":"stale","tag_description":"widespread failures or data too old to trust","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"verified","tag_description":"quickstart runs on critical runtimes, recently tested","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}