{"id":23629,"library":"dparse2","title":"dparse2","description":"A robust fork of the original dparse library with up-to-date dependency file parsing (pip requirements, Pipfile, conda env yml, poetry, setup.cfg). Version 0.7.0 supports Python 3.6+. Maintained by nexB.","status":"active","version":"0.7.0","language":"python","source_language":"en","source_url":"https://github.com/nexB/dparse2","tags":["parser","dependencies","pip","requirements","pipfile","conda","poetry"],"install":[{"cmd":"pip install dparse2","lang":"bash","label":"pip"}],"dependencies":[{"reason":"version comparison","package":"packaging","optional":false},{"reason":"parsing Pipfile and poetry files","package":"toml","optional":false},{"reason":"parsing conda yml files","package":"pyyaml","optional":false}],"imports":[{"note":"Original dparse used 'from dparse import parse'. The module is now dparse2.","symbol":"parse","correct":"from dparse2 import parse"},{"note":"Package name changed from dparse to dparse2.","wrong":"from dparse import filetypes","symbol":"filetypes","correct":"from dparse2.filetypes import RequirementsFile"},{"note":"Top-level package is dparse2, not dparse.","symbol":"dparse2","correct":"import dparse2"}],"quickstart":{"code":"from dparse2 import parse\nfrom dparse2.filetypes import RequirementsFile\n\nwith open('requirements.txt') as f:\n    content = f.read()\nparsed = parse(content, RequirementsFile)\nfor dep in parsed.dependencies:\n    print(dep.name, dep.specs)","lang":"python","description":"Parses a requirements.txt file and prints each dependency name and version specifier."},"warnings":[{"fix":"Replace 'import dparse' with 'import dparse2'.","message":"Package renamed from dparse to dparse2. All imports must use dparse2.","severity":"breaking","affected_versions":"all"},{"fix":"Upgrade to Python 3.6+ or use dparse2==0.5.0.1.","message":"Python 2.7 support dropped after 0.5.0.1. Versions 0.6+ require Python 3.6+.","severity":"breaking","affected_versions":">=0.6.0"},{"fix":"Use 'if parsed.dependencies: for dep in parsed.dependencies: ...'","message":"parse() returns a ParsedFile object; dependencies can be empty if file is malformed. Always check dependencies before iteration.","severity":"gotcha","affected_versions":"all"},{"fix":"Pass base_dir parameter to parse() to control relative path resolution.","message":"RequirementsFile parser expects base directory (default: '.'). Relative paths in requirements.txt are resolved against the base dir.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'pip install dparse2' and change imports to 'import dparse2'.","cause":"Package renamed to dparse2; old import fails.","error":"ModuleNotFoundError: No module named 'dparse'"},{"fix":"Use 'from dparse2 import parse' or 'dparse2.parse(...)'.","cause":"Wrong import path; parse is a function, not a module attribute when using 'import dparse2'.","error":"AttributeError: module 'dparse2' has no attribute 'parse'"},{"fix":"Provide a file type, e.g., 'from dparse2.filetypes import RequirementsFile' and call 'parse(content, RequirementsFile)'.","cause":"parse() requires a file type class as second argument.","error":"TypeError: parse() missing 1 required positional argument: 'file_type'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}