FastAPI "python-multipart must be installed to use Form"/"UploadFile" in CI
FastAPI parses form fields and file uploads with the optional python-multipart package. Any endpoint using Form(...) or UploadFile raises at startup or request time if that package is not installed in CI.
What this error means
App startup or a form test fails with "RuntimeError: Form data requires \"python-multipart\" to be installed." or the equivalent message for UploadFile.
RuntimeError: Form data requires "python-multipart" to be installed.
You can install "python-multipart" with:
pip install python-multipartCommon causes
python-multipart is not a declared dependency
FastAPI lists it as optional; endpoints that use Form or UploadFile fail without it, and a clean CI environment does not have it.
Tests exercise a form or upload route
A test posts multipart data to a route that needs the parser, so the missing package surfaces only in CI.
How to fix it
Install python-multipart
Add the package to your dependencies so form and file endpoints work on every runner.
python -m pip install python-multipartPin it in your dependency file
Declare it alongside FastAPI so CI never relies on it being incidentally present.
# requirements.txt
fastapi
uvicorn[standard]
python-multipartHow to prevent it
- Declare python-multipart whenever you use Form or UploadFile.
- Install the
fastapi[all]extra if you want the optional deps bundled. - Add a form or upload test so a missing parser fails CI early.