{"id":21775,"library":"pypcd4","title":"pypcd4","description":"A Python library for reading and writing PCL (Point Cloud Library) .pcd files, supporting ASCII, binary, and binary_compressed encodings. Current version: 1.4.3, requires Python >=3.8.2, released under MIT license on GitHub.","status":"active","version":"1.4.3","language":"python","source_language":"en","source_url":"https://github.com/MapIV/pypcd4","tags":["pcd","point-cloud","pcl","lidar","3d"],"install":[{"cmd":"pip install pypcd4","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"PointCloud data is stored as numpy arrays","package":"numpy","optional":false},{"reason":"Handles LZF decompression for binary_compressed PCD files","package":"python-neo-lzf","optional":false},{"reason":"Used for data validation and settings management","package":"pydantic","optional":false}],"imports":[{"note":"Standard import path","wrong":null,"symbol":"PointCloud","correct":"from pypcd4 import PointCloud"},{"note":"Alternative import if using submodule directly","wrong":null,"symbol":"PointCloud","correct":"from pypcd4.point_cloud import PointCloud"},{"note":"Aliasing is fine, but avoid confusing imports from older libraries like pypcd (without 4)","wrong":"from pypcd4 import PointCloud as PC","symbol":"PointCloud","correct":"import pypcd4; pypcd4.PointCloud"}],"quickstart":{"code":"from pypcd4 import PointCloud\nimport numpy as np\n\n# Create a simple point cloud\npc = PointCloud.from_xyz_points(np.array([[0,0,0],[1,0,0],[0,1,0]], dtype=np.float32))\nprint(pc)\n\n# Save to file\npc.save('example.pcd')\n\n# Load from file\nloaded = PointCloud.from_path('example.pcd')\nprint(loaded.pc_data)  # numpy structured array","lang":"python","description":"Create, save, and load a PCD point cloud"},"warnings":[{"fix":"Re-save any existing binary_compressed PCD files after upgrading to 1.3.0+. If reading old files fails, re-save them in ASCII or binary uncompressed.","message":"Binary_compressed encoding changed in v1.3.0: save/load logic was fixed, which may break compatibility with files created by older versions (<=1.2.1). If you compress with v1.3.0+, older versions may not read them correctly.","severity":"breaking","affected_versions":">=1.3.0"},{"fix":"Ensure your system supports python-neo-lzf. If installation fails, try pinning pypcd4<=1.3.0 or installing with --no-deps and manually adding python-lzf.","message":"The 'lzf' dependency changed in v1.4.0: 'python-lzf' was replaced with 'python-neo-lzf'. Install may break on older environments if 'python-neo-lzf' is not available for your platform (aarch64 fallback exists but can be problematic).","severity":"deprecated","affected_versions":">=1.4.0"},{"fix":"Access fields by name: pc.pc_data['x'], pc.pc_data['y'], pc.pc_data['z']. For RGB, note that it's packed into a 32-bit integer; use pc.pc_data['rgb'] and unpack with view(np.uint8).","message":"PointCloud.pc_data is a numpy structured array, and field access uses column names (e.g., 'x', 'y', 'z', 'rgb'). Attempting to access by index on the structured array may produce unexpected results.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure all point clouds to merge have identical schema. Use PointCloud.fields to inspect before merging.","message":"When creating from lists using 'from_list', all PointCloud objects must share the same field names/types. Mixing different fields will raise a ValueError.","severity":"gotcha","affected_versions":">=1.2.0"},{"fix":"Always use .pcd extension for compatibility.","message":"Saving to a file with extension other than .pcd is allowed but may cause issues with other PCD readers. The library does not validate the extension.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Install pypcd4 (pip install pypcd4) and import correctly: from pypcd4 import PointCloud","cause":"Using wrong import path or installing older/conflicting package (e.g., pypcd instead of pypcd4).","error":"AttributeError: module 'pypcd4' has no attribute 'PointCloud'"},{"fix":"Install pypcd4 with its dependencies: pip install pypcd4. For Python<3.8, you may need to manually install python-neo-lzf or python-lzf.","cause":"Missing lzf dependency when using binary_compressed PCD format.","error":"ModuleNotFoundError: No module named 'lzf'"},{"fix":"Use numpy element-wise comparison: pc.pc_data['x'][pc.pc_data['x'] == 0] or (pc.pc_data['x'] == 0).any()","cause":"Attempting to compare numpy arrays from pc_data in a boolean context, e.g., if pc.pc_data['x'] == 0:","error":"ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()"},{"fix":"Check the PCD file header to determine correct encoding. Use PointCloud.from_path(filename) for auto-detection.","cause":"Reading a PCD file with binary encoding as binary_compressed, or vice versa. The library auto-detects but can fail if file is malformed.","error":"UnicodeDecodeError: 'utf-8' codec can't decode byte 0x..."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}