{"id":21772,"library":"pynrrd","title":"pynrrd","description":"Pure Python library for reading and writing NRRD (Nearly Raw Raster Data) files, compatible with NumPy. Version 1.1.3 supports Python >=3.7 and NumPy >=1.21. Release cadence is sporadic, with occasional maintenance updates.","status":"active","version":"1.1.3","language":"python","source_language":"en","source_url":"https://github.com/mhe/pynrrd","tags":["nrrd","medical imaging","raster data","numpy"],"install":[{"cmd":"pip install pynrrd","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required for array manipulation.","package":"numpy","optional":false}],"imports":[{"note":"Use 'import nrrd' and call nrrd.read(), not the package name directly.","wrong":"from pynrrd import read","symbol":"read","correct":"import nrrd; nrrd.read()"},{"note":"Use 'import nrrd' and call nrrd.write().","wrong":"from pynrrd import write","symbol":"write","correct":"import nrrd; nrrd.write()"}],"quickstart":{"code":"import nrrd\nimport numpy as np\n\n# Write a NRRD file\ndata = np.random.rand(10, 10, 10)\nnrrd.write('example.nrrd', data)\n\n# Read a NRRD file\nread_data, header = nrrd.read('example.nrrd')\nprint(header)\n","lang":"python","description":"Basic read/write example using numpy array."},"warnings":[{"fix":"Upgrade to Python 3.7+ and use pynrrd >=1.0.0.","message":"pynrrd v1.0.0 dropped support for Python 2 and Python 3.6 and below.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Upgrade NumPy to >=1.21.","message":"v1.1.0 dropped support for NumPy <1.21. If you use an older NumPy, pynrrd 1.1.0+ will not install.","severity":"breaking","affected_versions":">=1.1.0"},{"fix":"Call np.asarray(data) or data.copy() to get a writable array.","message":"nrrd.read() returns the data as a numpy array. If the file is compressed, the array may be read-only. To modify it, use np.array(data).","severity":"gotcha","affected_versions":"all"},{"fix":"Always use 'import nrrd' (not 'import pynrrd').","message":"Using pip install pynrrd while the import is import nrrd can confuse users. The package name on PyPI is pynrrd, but the module is nrrd.","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":"Use 'import nrrd' instead of 'import pynrrd'.","cause":"Attempting to import pynrrd directly; the module is named nrrd.","error":"ImportError: No module named pynrrd"},{"fix":"Verify the file integrity and ensure the header dimensions (sizes) match the data.","cause":"The data in the NRRD file is corrupted or the header dimensions do not match the actual data size.","error":"NRRDError: 'Size of the data does not equal to the product of all dimensions'"},{"fix":"Do not close the file object before nrrd.read() finishes. If using a context manager, read inside the with block.","cause":"Trying to use a file object that has been closed before reading.","error":"ValueError: cannot read from a closed file"},{"fix":"Ensure you pass a proper array-like object. For a read-only array, just use data.copy() if needed.","cause":"If the data is already a numpy array, np.array(data) is fine; this error may occur with other misuse.","error":"TypeError: numpy() takes at most 1 argument (2 given) (when using np.array(data))"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}