{"id":28080,"library":"pycifrw","title":"PyCIFRW","description":"PyCIFRW provides support for reading and writing CIF (Crystallographic Information File) and STAR files in Python. Version 5.0.1 is the latest stable release, with a focus on bugfixes and dropping Python 2 support. The library is maintained with occasional releases.","status":"active","version":"5.0.1","language":"python","source_language":"en","source_url":"https://github.com/jamesrhester/pycifrw","tags":["CIF","crystallography","STAR","file-parser"],"install":[{"cmd":"pip install pycifrw","lang":"bash","label":"Latest from PyPI"}],"dependencies":[],"imports":[{"note":"Common mistake: users try to import from the top-level package name.","wrong":"from pycifrw import ReadCif","symbol":"ReadCif","correct":"from CifFile import ReadCif"},{"note":"Import path is CifFile, not pycifrw.","wrong":"from pycifrw import CifFile","symbol":"CifFile","correct":"from CifFile import CifFile"},{"note":"","wrong":"","symbol":"StarFile","correct":"from StarFile import StarFile"}],"quickstart":{"code":"from CifFile import ReadCif\n# Replace with an actual CIF file path or content\ncif_content = \"\"\"data_test\n_audit_creation_method 'manually created'\n\"\"\"\nwith open('test.cif', 'w') as f:\n    f.write(cif_content)\nast = ReadCif('test.cif')\nprint(ast.keys())\n# Clean up\nimport os\nos.remove('test.cif')","lang":"python","description":"Read a CIF file and print the top-level keys. Note: the input CIF must exist. For demo, we write a minimal CIF first."},"warnings":[{"fix":"Upgrade to Python 3, or pin to pycifrw==4.4.6 if stuck on Python 2.","message":"Version 5.0 dropped Python 2 support entirely. Code written for Python 2 will not run.","severity":"breaking","affected_versions":">=5.0"},{"fix":"Use `from CifFile import ReadCifWithError` and handle returned parse info.","message":"The function `ReadCif` still works but `ReadCifWithError` is recommended for more robust parsing.","severity":"deprecated","affected_versions":">=5.0"},{"fix":"Use `from CifFile import ReadCif` instead of `from pycifrw import ReadCif`.","message":"Importing from `pycifrw` directly fails. The correct import path is `CifFile`, `StarFile`, etc.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'2':33 '5.0.1':19 'bugfix':29 'cif':9,42 'crystallograph':10 'crystallographi':43 'drop':31 'file':12,15,46 'file-pars':45 'focus':27 'inform':11 'latest':22 'librari':36 'maintain':38 'occasion':40 'parser':47 'provid':3 'pycifrw':1,2 'python':17,32 'read':6 'releas':24,41 'stabl':23 'star':14,44 'support':4,34 'version':18 'write':8","created_at":"2026-05-09T05:53:37.667050+00:00","updated_at":"2026-05-09T05:53:37.667050+00:00","problems":[{"fix":"Install with `pip install pycifrw` but import from 'CifFile' (e.g., `from CifFile import ReadCif`).","cause":"Trying to `import pycifrw` or `from pycifrw import ...`. The top-level module is not 'pycifrw'—the actual modules are CifFile, StarFile, etc.","error":"ModuleNotFoundError: No module named 'pycifrw'"},{"fix":"Ensure Python 3 interpreter is used (python3). If stuck on Python 2, install pycifrw==4.4.6.","cause":"Running Python 2 code on Python 3. PyCIFRW 5+ requires Python 3.","error":"SyntaxError: invalid syntax (for print statements, etc.)"},{"fix":"Use `ReadCifWithError` to get partial results, or check the CIF syntax. Access data via `ast.first_loop()['_tag']` or convert to dict: `dict(ast.items())`.","cause":"Reading a CIF file with errors; the object may be incomplete. Or using wrong method to access data.","error":"AttributeError: 'CifFile' object has no attribute 'keys'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/jamesrhester/pycifrw","docs":null,"changelog":null,"pypi":"https://pypi.org/project/pycifrw/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-29","last_verified":"2026-06-29","next_check":"2026-07-29","install_tag":null}}