LlamaIndex cannot import Ollama from llama_index.llms
ImportError: cannot import name 'Ollama' from 'llama_index.llms' (unknown location)Short answer
Since LlamaIndex 0.10, each integration is its own package and the old top-level llama_index.llms path is gone. Install llama-index-llms-ollama and import Ollama from llama_index.llms.ollama. The model server must also be running, and slow models may need a longer request_timeout.
Fix it fast
1Find out which cause you have
List the installed LlamaIndex packages. The integration package must appear next to llama-index-core.
python -m pip list | grep -i llama2Match what you see, then jump to its fix
- 1
The failing line is from llama_index.llms import OllamaOld import path from before the 0.10 package splitFix - 2
The new import path fails, while llama-index itself is installedThe Ollama integration package is not installedFix - 3
A timeout after about 30 seconds on a big model, or a connection error to localhost:11434The import works but the first call times out or cannot connectFix
- 1
What does the error look like?
ImportError: cannot import name 'Ollama' from 'llama_index.llms' (unknown location)
Cause 1 of 3
Old import path from before the 0.10 package split
1Check
The LlamaIndex 0.10 migration post says integrations became separate packages and that llama_index.llms can no longer be used as a top-level import.
grep -rn "from llama_index.llms import\|from llama_index import" --include='*.py' .2Fix
Change the import to the namespaced path, or let the upgrade command rewrite the folder for you.
from llama_index.llms.ollama import Ollama
# or rewrite the whole source folder
llamaindex-cli upgrade ./src3Verify
The import runs.
python -c "from llama_index.llms.ollama import Ollama; print('ok')"Confirmed by llamaindex.ai
Cause 2 of 3
The Ollama integration package is not installed
1Check
The installation guide says pip install llama-index brings a starter bundle: core, OpenAI LLM and embeddings, and file readers. Ollama is not in it.
python -m pip show llama-index-llms-ollama2Fix
Install the integration into the interpreter that runs your code.
python -m pip install llama-index-llms-ollama3Verify
The package shows up and imports.
python -m pip show llama-index-llms-ollamaConfirmed by developers.llamaindex.ai
Cause 3 of 3
The import works but the first call times out or cannot connect
1Check
The LlamaIndex Ollama notebook says the default timeout is 30 seconds, and the class talks to the server at http://localhost:11434 unless you pass base_url. The server has to be running and the model pulled first.
ollama list
curl -s http://localhost:114342Fix
Start the server, pull the model, and raise request_timeout when constructing the class.
ollama serve
ollama pull llama3.1
# python
llm = Ollama(model="llama3.1:latest", request_timeout=120.0)3Verify
A completion returns text.
print(llm.complete("Say hello in one word."))Confirmed by developers.llamaindex.ai
How do I stop it coming back?
- Install each LlamaIndex integration by name and keep core and integrations upgraded together.
- Search new code and tutorials for from llama_index.llms import and fix it on sight.
- Set request_timeout explicitly instead of relying on the 30-second default.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- stegnor.comMy company site: 804 pages from a Python and Jinja generator, with 15 free browser tools.
- MenuloA restaurant discovery platform in Germany, kept current by a Python ingestion pipeline.
- ShopGoAn e-commerce aggregator with a Python scraping engine behind its catalog, past 10K Google Play downloads.
Related fixes
AI
LlamaIndex gets 404 Not Found from Ollama at /api/chat
Client error '404 Not Found' for url 'http://localhost:11434/api/chat'
Ollama's error docs describe 404 as a resource that was not found, such as a model that does not exist.
2 causes, each with a fixAI
ollama Python library fails with httpx.ConnectError
httpx.ConnectError
httpx.ConnectError means the client could not open a connection to the address it used.
3 causes, each with a fixAI
Azure OpenAI says the API deployment for this resource does not exist
The API deployment for this resource does not exist
Azure OpenAI does not take a model name in the model field.
2 causes, each with a fixAI
Azure OpenAI fails with an SSL certificate verification error
httpx.ConnectError: [SSL: CERTIFICATE_VERIFY_FAILED]
The client checks the endpoint's certificate against its CA bundle, which is certifi by default.
2 causes, each with a fixAI
LangChain says it could not import the chromadb package
ImportError: Could not import chromadb python package. Please install it with `pip install chromadb`.
The message comes from LangChain's old Chroma class, which cannot import chromadb in the Python that runs your code.
2 causes, each with a fixAI
Gemini API returns 429 RESOURCE_EXHAUSTED on the free tier
429 RESOURCE_EXHAUSTED
Gemini limits are applied per Google Cloud project, not per API key, so a new key in the same project does not reset anything.
3 causes, each with a fix