# Install Packages

Add Python libraries to your deployment endpoints using a requirements file. Valohai installs these when building your deployment.

### Create requirements file

Add a file named `requirements-deployment.txt` to your repository:

```
sqlalchemy==2.0.0
fastapi==0.104.1
pydantic==2.5.0
```

**If `requirements-deployment.txt` doesn't exist**, Valohai falls back to `requirements.txt`

### Why separate files?

**Training requirements** (`requirements.txt`):

* Heavy ML libraries (TensorFlow, PyTorch)
* Data processing tools (pandas, scikit-learn)
* Experiment tracking (MLflow, Weights & Biases)

**Deployment requirements** (`requirements-deployment.txt`):

* Lightweight inference libraries
* Web frameworks (FastAPI, Flask)
* Production utilities (monitoring, logging)

Keeping them separate results in smaller, faster-loading deployment images.

### When packages install

Valohai installs packages when you **create a new deployment version**. If you update requirements:

1. Commit and push the changes
2. Create a new deployment version
3. Packages install during the build process

### Troubleshooting

**Package not found during runtime:**

* Verify it's in `requirements-deployment.txt`
* Check build logs for installation errors
* Ensure the package name and version are correct

**Deployment build fails:**

* Look for dependency conflicts in build logs
* Pin versions explicitly: `fastapi==0.104.1` instead of `fastapi`
* Test locally first: `pip install -r requirements-deployment.txt`

***

**Next:** Learn how to [troubleshoot deployments](https://github.com/valohai/dokuhai/blob/main/docs/debug.md) when things go wrong.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.valohai.com/serving-your-models/real-time-endpoints/install-packages.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
