High severity beginner · Fix: 2-5 min

OllamaModelNotFoundError

ollama.client.OllamaModelNotFoundError

What this error means
Ollama client throws 'model not found pull required' when the requested model is not locally available and must be pulled before use.

Stack trace

traceback
Traceback (most recent call last):
  File "app.py", line 42, in <module>
    response = client.chat.completions.create(model="llama2", messages=messages)
  File "/usr/local/lib/python3.10/site-packages/ollama/client.py", line 120, in create
    raise OllamaModelNotFoundError("Model not found locally. Pull required.")
ollama.client.OllamaModelNotFoundError: Model not found locally. Pull required.
QUICK FIX
Run 'ollama pull <model_name>' to download the missing model before running your code.

Why it happens

This error occurs because the Ollama client expects the requested model to be available locally. If the model has not been pulled or downloaded to the local environment, the client cannot instantiate it and raises this error.

Detection

Check for OllamaModelNotFoundError exceptions when calling model inference methods; log the model name and verify local model availability before proceeding.

Causes & fixes

1

The requested Ollama model is not downloaded locally on the machine.

✓ Fix

Run 'ollama pull <model_name>' in your terminal to download the model before using it in your code.

2

Model name specified in code is misspelled or incorrect.

✓ Fix

Verify the exact model name available via 'ollama list' and correct the model parameter in your code.

3

Ollama client environment does not have access to the model storage or cache directory.

✓ Fix

Ensure the Ollama client has proper permissions and environment variables set to access the local model storage.

Code: broken vs fixed

Broken - triggers the error
python
import ollama
response = ollama.chat(model="llama2", messages=[{"role": "user", "content": "Hello"}])  # Raises OllamaModelNotFoundError
Fixed - works correctly
python
import ollama
# Ensure model is pulled before usage
# Run in terminal: ollama pull llama2
response = ollama.chat(model="llama2", messages=[{"role": "user", "content": "Hello"}])
print(response)
Added instruction to pull the model locally before usage, ensuring the Ollama client can find and load the model without error.

Workaround

Catch OllamaModelNotFoundError in your code and programmatically run a subprocess call to 'ollama pull <model_name>' to download the model before retrying the request.

Prevention

Always verify and pull required Ollama models during deployment or initialization phases to guarantee local availability and avoid runtime errors.

Python 3.8+ · ollama >=0.1.0 · tested on 0.1.x
Verified 2026-04
Verify ↗

Community Notes

No notes yetBe the first to share a version-specific fix or tip.