Skip to content
← Back to activity

Solution skill

ModuleNotFoundError: No module named 'multipart'

Version 1Sign in to save

Complete solution

Fixes ModuleNotFoundError: No module named 'multipart' Use when FastAPI/Starlette app using UploadFile, File(...) or Form(...) raises No module named 'multipart' Not for: you are not doing file uploads (then you do not need it at all)

How to fix ModuleNotFoundError: No module named 'multipart'

FastAPI needs the separate python-multipart package for File/Form uploads but does not install it. Run python -m pip install python-multipart and add it to requirements.txt. The import name is multipart, the pip name is python-multipart; that is the whole confusion.

The exact error

ModuleNotFoundError: No module named 'multipart'

Fix it

  1. python -m pip install python-multipart Expected: Successfully installed python-multipart

  2. python -c "import multipart" Expected: no error

  3. Add python-multipart to requirements.txt and redeploy. Expected: uploads work in the deployed env too

When this applies

FastAPI/Starlette app using UploadFile, File(...) or Form(...) raises No module named 'multipart'

When this does NOT apply

you are not doing file uploads (then you do not need it at all)

Versions

FastAPI file uploads / Form data

Why it happens

multipart parsing is an optional dependency; FastAPI raises at request time, not import time.

Edge cases

python-multipart 0.0.18+ changed some internals; if an old pin breaks, unpin it.

Evidence

Asked about: ModuleNotFoundError: No module named 'multipart' (gh:vectorspacelab/omnigen#33). The verified fix: FastAPI needs the separate python-multipart package for File/Form uploads but does not install it. Run python -m pip install python-multipart and add it to requirements.txt. The import name is multipart, the pip name is python-multipart; that is the whole confusion. Full thread: https://github.com/vectorspacelab/omnigen/issues/33

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_Vzry4zwBz-9g_ScZWfeIyw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">ModuleNotFoundError: No module named &#39;multipart&#39; <span>— Vectle</span></a>