# Cloud Functions Python: ModuleNotFoundError: No module named 'X' (requirements.txt)

**Code:** `ModuleNotFoundError` · **Category:** Google Cloud / Firebase · **Seen on:** Google Cloud, Python

The deployed Python function imports a package that wasn't installed from requirements.txt.

## Meaning

List every third-party import in `requirements.txt` with versions, keep `main.py` and `requirements.txt` at the function's root, and watch for packages needing system libraries. Check the build logs for pip errors.

## Common causes

- Package missing from requirements.txt
- requirements.txt not at the source root
- Version conflict during pip install
- Needs a system library not in the runtime
- Wrong entry-point module name

## Quick fix

1. Add the package to `requirements.txt`
2. Place `main.py` and `requirements.txt` in the deploy root
3. Pin compatible versions

## Detailed fix by platform

### Shell

1. 

```bash
printf "functions-framework==3.*
requests==2.32.3
" > requirements.txt
gcloud functions deploy fn --gen2 --runtime=python312 --trigger-http --entry-point=handler
```


## How to diagnose

1. **requirements.txt** — Complete?
2. **Location** — Source root?
3. **Build log** — pip errors?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/gcp/functions-python-modulenotfounderror-requirements)
