[▲ Vercel Community](/) · [Categories](/categories) · [Latest](/latest) · [Top](/top) · [Live](/live) [Help](/c/help/9) # FastAPI on Vercel Function: ModuleNotFoundError: No module named 'pydantic_core._pydantic_core' 218 views · 3 likes · 6 posts Nfomis (@nfomis) · 2025-12-30 · ♥ 1 I’m deploying a development branch as preview with a FastAPI backend located at src/api/index.py. When hitting the api/auth/me route, I’m getting a `ModuleNotFoundError: No module named 'pydantic_core._pydantic_core` The code in src/api/index.py has changed very little compared to the current production deployment (only a few lines were added). The requirements in src/api/pyproject.toml are identical to what’s deployed in production with pinned versions I know are present in the current production version. The build completes successfully and the Python dependencies install without errors, but at runtime in the Vercel Function Lambda environment, pydantic_core cannot be found. I suspect this issue is due to a changed way in which Vercel bundles Python functions in the Lambda environment. The current behaviour is the one described, the expected one is for the backend to run smoothly since the requirements did not change. In production `pyproject.toml` ```toml [project] name = "my-prj-api" version = "0.1.0" description = "Add your description here" readme = "README.md" requires-python = ">=3.11" dependencies = [ "boto3>=1.40.61", "fastapi>=0.120.0", "pydantic>=2.12.3", "python-dotenv>=1.1.1", "requests>=2.32.5", "supabase>=2.22.2", "uvicorn[standard]>=0.38.0", ] [dependency-groups] dev = [ "pytest>=8.4.2", "ruff>=0.14.6", "mypy>=1.18.2", "boto3-stubs>=1.41.4", "types-requests>=2.32.4.20250913", ] ``` development branch `pyproject.toml` with pinned versions as per the ones in the last production deployment ```toml [project] name = "timely-api" version = "0.1.0" description = "Add your description here" readme = "README.md" requires-python = ">=3.11" dependencies = [ "boto3>=1.40.61", "fastapi==0.120.1", "pydantic==2.12.3", "pydantic-settings==2.11.0", "pydantic-core==2.41.4", "python-dotenv>=1.1.1", "requests>=2.32.5", "supabase>=2.22.2", "uvicorn[standard]>=0.38.0", ] [dependency-groups] dev = [ "pytest>=8.4.2", "ruff>=0.14.6", "mypy>=1.18.2", "boto3-stubs>=1.41.4", "types-requests>=2.32.4.20250913", ] ``` <!-- Project information (URL, framework, environment, project settings) --> Anyone experiencing the same? Swarnava Sengupta (@swarnava) · 2026-01-02 · ♥ 1 Hi, Do you have `.python-version` in your project? Could you temporarily enable source code visibility so we can take a look? https://vercel.com/kb/guide/how-to-allow-the-vercel-support-team-to-access-your-deployment-source-code AK (@alexkan) · 2026-01-05 I’m experiencing the exact same issue when running FastAPI with pydantic on Vercel Functions. I think it’s because `pydantic_core` is actually built with native code (Rust in this case) ….see this issue from pydantic https://github.com/pydantic/pydantic/issues/6557. It looks like Vercel’s Python runtime is using an `x86_64` architecture, so I tried installing the package directly using the following command, but still no luck. See these docs from AWS: https://docs.aws.amazon.com/lambda/latest/dg/python-package.html#python-package-native-libraries I ran this command in the build via: \[tool.verson.scripts\] pip install -r requirements.txt && pip install --platform manylinux2014_x86_64 --target package --implementation cp --python-version 3.12 --only-binary=:all: --upgrade pydantic The build succeeds, but navigating to the index of the app fails with the same error as OP. Help here would be appreciated!  Swarnava Sengupta (@swarnava) · 2026-01-06 Hi @alexkan, Could you enable source code visibility https://vercel.com/kb/guide/how-to-allow-the-vercel-support-team-to-access-your-deployment-source-code and share us the project? Nfomis (@nfomis) · 2026-01-09 · ♥ 1 I can confirm that removing \`.python-version\` from the folder where the backend lives solves the problem. Chamithroxmpc 6514 (@chamithroxmpc-6514) · 2026-01-18 ✅ This is the solution. It’s because of a version conflict