{"id":"5106e7f69f92d1db","repo":"pypa/pip","slug":"requirements-from-script-can-only-be-given-once","errorCode":null,"errorMessage":"--requirements-from-script can only be given once","messagePattern":"--requirements-from-script can only be given once","errorType":"exception","errorClass":"CommandError","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/cli/req_command.py","lineNumber":400,"sourceCode":"                continue\n            for parsed_req in parse_requirements(\n                filename, finder=finder, options=options, session=session\n            ):\n                req_to_add = install_req_from_parsed_requirement(\n                    parsed_req,\n                    isolated=options.isolated_mode,\n                    user_supplied=True,\n                    config_settings=(\n                        parsed_req.options.get(\"config_settings\")\n                        if parsed_req.options\n                        else None\n                    ),\n                )\n                requirements.append(req_to_add)\n\n        if options.requirements_from_scripts:\n            if len(options.requirements_from_scripts) > 1:\n                raise CommandError(\"--requirements-from-script can only be given once\")\n\n            script = options.requirements_from_scripts[0]\n            try:\n                script_metadata = pep723_metadata(script)\n            except PEP723Exception as exc:\n                raise CommandError(exc.msg)\n\n            script_requires_python = script_metadata.get(\"requires-python\", \"\")\n\n            if script_requires_python and not options.ignore_requires_python:\n                target_python = make_target_python(options)\n\n                if not check_requires_python(\n                    requires_python=script_requires_python,\n                    version_info=target_python.py_version_info,\n                ):\n                    raise UnsupportedPythonVersion(\n                        f\"Script {script!r} requires a different Python: \"","sourceCodeStart":382,"sourceCodeEnd":418,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_internal/cli/req_command.py#L382-L418","documentation":"Raised by RequirementCommand.get_requirements() in req_command.py:400 when --requirements-from-script is specified more than once. PEP 723 inline script metadata can only come from a single script file; multiple scripts would create ambiguous dependency resolution, so pip enforces a limit of one.","triggerScenarios":"Calling `pip install --requirements-from-script a.py --requirements-from-script b.py`. The check at req_command.py:399 verifies len(options.requirements_from_scripts) > 1.","commonSituations":"Build scripts or Makefiles that accumulate --requirements-from-script flags in a loop. Combining multiple PEP 723 scripts in one pip install call. Misunderstanding that only one script is supported.","solutions":["Use only one --requirements-from-script per pip install invocation.","Run separate pip install commands for each script.","Merge dependencies from multiple scripts into a single requirements file or a single PEP 723 script."],"exampleFix":"# before\npip install --requirements-from-script a.py --requirements-from-script b.py\n\n# after\npip install --requirements-from-script a.py\npip install --requirements-from-script b.py","handlingStrategy":"validation","validationCode":"def validate_single_script(scripts):\n    \"\"\"Ensure only one --requirements-from-script is given.\"\"\"\n    if isinstance(scripts, list) and len(scripts) > 1:\n        raise ValueError('--requirements-from-script can only be given once')\n    return True","typeGuard":null,"tryCatchPattern":"from pip._internal.exceptions import CommandError\ntry:\n    # pip install --requirements-from-script ...\nexcept CommandError as e:\n    if '--requirements-from-script' in str(e) and 'once' in str(e):\n        # split into separate pip invocations\n","preventionTips":["Pass only one script per pip install command.","If you need deps from multiple scripts, merge them into a single requirements file.","Validate argument counts in wrapper scripts before calling pip."],"tags":["cli","pep723","option-conflict","requirements-from-script","validation"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}