{"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,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","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,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}