mirror of
https://github.com/ollama/ollama-python.git
synced 2026-07-21 09:05:23 -04:00
LlamaIndex Fails to Connect to Ollama in Conda Environment, Works in Command Prompt #232
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @JANVI2411 on GitHub (Mar 8, 2025).
I'm facing an issue where LlamaIndex's Ollama integration is not working, even though I have installed all necessary dependencies. The same Ollama model works fine using the Python library, but it times out or fails when used inside LlamaIndex.
Additionally, !ollama list works fine in Command Prompt but not inside the Conda environment, even after setting the path
[Created Conda environment]
Environment Details:
Operating System: Windows 11
Python Version: 3.9.13
Ollama Version: 0.5.13
LlamaIndex Version: 0.12.23
How Ollama is installed: Windows installer (installed in C:\Users\janvi\AppData\Local\Programs\Ollama)
✅ Ollama Works in Python
Running Ollama directly via Python works fine in the jupyter notebook:
✅ This outputs a valid response, meaning the model is installed and working.
❌ Issue with LlamaIndex’s Ollama Wrapper
However, when using LlamaIndex’s Ollama wrapper, it fails or times out:
❌ !ollama list Works in cmd but Not in Conda
When running:
!ollama list✅ Works fine in Command Prompt (cmd)
❌ Fails in Conda Jupyter Notebook
❌ Fails inside Conda environment in VS Code
✅ Running ollama serve works fine in cmd but not accessible in Conda.
✅Running below command works fine in Conda environment in jupyter notebook
!C:\Users\janvi\AppData\Local\Programs\Ollama\ollama.exe list📌 What I’ve Tried
✅ Verified Ollama is installed and running (ollama serve).
✅ Checked if http://127.0.0.1:11434/api/tags is accessible (requests.get() test).
✅ Manually set OLLAMA_HOST=http://127.0.0.1:11434.
✅ Tried adding Ollama’s path manually inside Conda:
set PATH=%PATH%;C:\Users\janvi\AppData\Local\Programs\Ollama\✅ Increased request_timeout=120.0 but still fails.
✅ Installed latest versions:
✅ Tried different models (mistral, llama2), but same issue.
@JANVI2411 commented on GitHub (Mar 8, 2025):
It got resolved finally!
Running the below commands and then restarting the Jupyter notebook
Earlier I was adding the path temporary, which was not working at all!
Now the above command will add the ollama permanently in the conda environment
Also increase the timeout to 40-50 secs