Deploy start to fail with uvicorn: command not found

23:56:32.836 Running build in Washington, D.C., USA (East) – iad1
23:56:32.837 Build machine configuration: 2 cores, 8 GB
23:56:32.846 Cloning github.com/qinzzz/Musee (Branch: main, Commit: ac3d178)
23:56:32.846 Skipping build cache, deployment was triggered without cache.
23:56:33.468 Cloning completed: 622.000ms
23:56:33.880 Running "vercel build"
23:56:34.273 Vercel CLI 48.9.2
23:56:34.473 Running "uvicorn app.main:app --reload --host 0.0.0.0 --port 8000"
23:56:34.476 sh: line 1: uvicorn: command not found
23:56:34.479 Error: Command "uvicorn app.main:app --reload --host 0.0.0.0 --port 8000" exited with 127

My python fastAPI backend stopped to work since today although i didn’t make any python environment changes. To make sure it’s not from my code change, I tried to redeploy a change 3 days ago, but it failed with the exact same code, while it succedded before. The error message is as above.
The previous successful log is like this

`22:28:37.895 Build machine configuration: 2 cores, 8 GB
22:28:38.040 Cloning ``github.com/qinzzz/Musee`` (Branch: main, Commit: 213456f)`
`22:28:38.041 Previous build caches not available.`
`22:28:38.675 Cloning completed: 635.000ms`
`22:28:39.132 Running "vercel build"`
`22:28:39.967 Vercel CLI 48.9.1`
`22:28:40.186 No Python version specified in pyproject.toml or Pipfile.lock. Using latest installed version: 3.12`
`22:28:40.192 Installing required dependencies from requirements.txt...`
`22:28:40.193 Using uv at "/usr/local/bin/uv"`
`22:28:43.816 Build Completed in /vercel/output [4s]`
`22:28:44.130 Deploying outputs...`
`22:29:03.918 Deployment completed`
`22:29:04.540 Creating build cache...`
`22:29:04.604 Skipping cache upload because no files were prepared.`

Note that the python env instalation logs (Installing required dependencies from requirements.txt) are missing.

Build command: uvicorn app.main:app --reload --host 0.0.0.0 --port 8000

  • install command, development command are empty.
  • I don’t have a vercel.json file.
  • I use requirements.txt to configure python env.
  • Local build succeeds.

Looking at your logs, the issue is that your Python dependencies (including uvicorn) aren’t being installed during the build process. In your successful build, you can see the line “Installing required dependencies from requirements.txt…” but this is missing in the failed build.

This suggests a few potential issues:

  1. Missing requirements.txt: Make sure you have a requirements.txt file in your project root that includes uvicorn and other dependencies.

  2. Build command configuration: For Python/FastAPI projects on Vercel, you typically don’t need to specify the uvicorn command as your build command. Instead, you should:

    • Remove the custom build command
    • Let Vercel auto-detect your Python project
    • Create an api/ directory structure if you haven’t already
  3. Project structure: Vercel expects Python APIs to be in the api/ directory. Your FastAPI app should be structured like:

    api/ ├── main.py # or index.py └── requirements.txt

Try these steps:

  1. Ensure your requirements.txt includes uvicorn and fastapi
  2. Move your FastAPI code to the api/ directory
  3. Remove any custom build commands and let Vercel handle the deployment automatically

Resources:

removing the Build command fixes this issue! Is there anything changes recently regarding how you deploy python? i used the exact same config before but it only start to fail since 3 days ago.

I’m glad that worked for you!

What errors are you seeing now?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

Hey! We’re running this session next week after our recent announcement of Gel joining the team. Because you had posted about Python, I thought I’d give you a heads up in case you wanted to join us! :smiley: