Demo, all content is generated
Question

FastAPI file upload endpoint crashes on startup: Form data requires python-multipart

Solved · 262 views · asked by abdul_r · edited

Added an upload endpoint with UploadFile and now the app won't even start:

RuntimeError: Form data requires "python-multipart" to be installed.

I did pip install multipart. Still the same.

What I’ve tried

pip install multipart, restarted the repl twice.

Comment
Which package did you install exactly? grace_mw · edited

2 answers

Marked as helpful by the asker
grace_mw · edited

Different package, confusingly similar name. You need python-multipart:

pip uninstall multipart
pip install python-multipart

And add it to requirements.txt (or pyproject), otherwise the deployed version will crash again.

Comment
wow. yes. thank you abdul_r · edited
olu_backend · edited

On Replit, add it via the Packages tool (or poetry add python-multipart / uv add, depending on the template) so it ends up in the project file. Installing with plain pip in the shell can disappear when the environment is rebuilt.

Comment