{"record":{"id":"93df0e4177ef02d2","repo":"tiangolo/fastapi","slug":"form-data-requires-python-multipart-to-be-instal","errorCode":null,"errorMessage":"Form data requires \"python-multipart\" to be installed. It seems you installed \"multipart\" instead. \nYou can remove \"multipart\" with: \n\npip uninstall multipart\n\nAnd then install \"python-multipart\" with: \n\npip install python-multipart\n","messagePattern":"Form data requires \"python-multipart\" to be installed\\. It seems you installed \"multipart\" instead\\. \nYou can remove \"multipart\" with: \n\npip uninstall multipart\n\nAnd then install \"python-multipart\" with: \n\npip install python-multipart\n","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"fastapi/dependencies/utils.py","lineNumber":126,"sourceCode":"        assert __version__ > \"0.0.12\"\n    except (ImportError, AssertionError):\n        try:\n            # __version__ is available in both multiparts, and can be mocked\n            from multipart import (  # type: ignore[no-redef,import-untyped]\n                __version__,\n            )\n\n            assert __version__\n            try:\n                # parse_options_header is only available in the right multipart\n                from multipart.multipart import (  # type: ignore[import-untyped]\n                    parse_options_header,\n                )\n\n                assert parse_options_header\n            except ImportError:\n                logger.error(multipart_incorrect_install_error)\n                raise RuntimeError(multipart_incorrect_install_error) from None\n        except ImportError:\n            logger.error(multipart_not_installed_error)\n            raise RuntimeError(multipart_not_installed_error) from None\n\n\ndef get_parameterless_sub_dependant(*, depends: params.Depends, path: str) -> Dependant:\n    assert callable(depends.dependency), (\n        \"A parameter-less dependency must have a callable dependency\"\n    )\n    own_oauth_scopes: list[str] = []\n    if isinstance(depends, params.Security) and depends.scopes:\n        own_oauth_scopes.extend(depends.scopes)\n    return get_dependant(\n        path=path,\n        call=depends.dependency,\n        scope=depends.scope,\n        own_oauth_scopes=own_oauth_scopes,\n    )","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/tiangolo/fastapi/blob/3e8d1526d83a90aaf7d6eb6dc682bf150f180b25/fastapi/dependencies/utils.py#L108-L144","documentation":"RuntimeError raised by ensure_multipart_is_installed when the wrong package is present: `from python_multipart import __version__` failed (or version is too old) but `from multipart import __version__` succeeded, and then `from multipart.multipart import parse_options_header` failed with ImportError. The `multipart` package on PyPI is a different, incompatible library from `python-multipart`, which is what FastAPI/Starlette need to parse form/multipart bodies.","triggerScenarios":"An endpoint or dependency uses Form() or File() (multipart parsing), so FastAPI calls ensure_multipart_is_installed(), but the environment has `multipart` installed instead of `python-multipart`.","commonSituations":"A developer ran `pip install multipart` (wrong package, same import name) instead of `pip install python-multipart`; a transitive dependency pulled in the bare `multipart` package; an old requirements file with the wrong name; fastapi[standard] not installed and the correct package missing.","solutions":["Uninstall the wrong package and install the right one: pip uninstall multipart && pip install python-multipart.","Add python-multipart (not multipart) to requirements.txt / pyproject dependencies.","Install fastapi[standard], which already pulls python-multipart.","After fixing, verify with: python -c \"import python_multipart; print(python_multipart.__version__)\"."],"exampleFix":"# before\npip install multipart   # wrong package\n# -> RuntimeError: It seems you installed \"multipart\" instead.\n\n# after\npip uninstall multipart\npip install python-multipart","handlingStrategy":"fallback","validationCode":"# Verify the correct package is importable before using Form/File\nimport importlib.util, sys\n\nif importlib.util.find_spec(\"python_multipart\") is None:\n    print(\"python-multipart missing or wrong 'multipart' installed\")\n    sys.exit(1)\n\n# also guard against the wrong package shadowing the right one\nimport importlib\ntry:\n    importlib.import_module(\"multipart.multipart\")  # parse_options_header lives here\nexcept ImportError:\n    print(\"the wrong 'multipart' package is installed; install python-multipart\")\n    sys.exit(1)","typeGuard":null,"tryCatchPattern":"try:\n    from python_multipart import __version__\n    assert __version__ > \"0.0.12\"\nexcept (ImportError, AssertionError):\n    # fallback: refuse to start Form/File routes, or instruct install\n    raise RuntimeError(\"pip install python-multipart\")","preventionTips":["Always install python-multipart, never the bare `multipart` package.","Pin python-multipart in requirements.txt / pyproject explicitly.","Prefer fastapi[standard] so the correct parser is pulled in transitively.","After dependency changes, verify `import python_multipart` succeeds before deploying."],"tags":["multipart","installation","form-data","dependency","fastapi"],"backgroundTag":null,"analyzedSha":"3e8d1526d83a90aaf7d6eb6dc682bf150f180b25","analyzedAt":"2026-08-11T02:34:52.986Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}