LlamaIndex Fails to Connect to Ollama in Conda Environment, Works in Command Prompt #232

Closed
opened 2026-02-15 16:28:57 -05:00 by yindo · 1 comment
Owner

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:

import ollama

response = ollama.chat(
    model="llama3.2:1b",
    messages=[{"role": "user", "content": "Hello!"}]
)

print(response["message"])

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:

from llama_index.llms.ollama import Ollama

llm = Ollama(model="llama3.2:1b", request_timeout=30)

response = llm.complete("Hi, What is your name?")
print(response)

!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.

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: ``` import ollama response = ollama.chat( model="llama3.2:1b", messages=[{"role": "user", "content": "Hello!"}] ) print(response["message"]) ``` ✅ 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: ``` from llama_index.llms.ollama import Ollama llm = Ollama(model="llama3.2:1b", request_timeout=30) response = llm.complete("Hi, What is your name?") print(response) ``` ❌ !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.
yindo closed this issue 2026-02-15 16:28:57 -05:00
Author
Owner

@JANVI2411 commented on GitHub (Mar 8, 2025):

It got resolved finally!

Running the below commands and then restarting the Jupyter notebook

conda activate <your_env_name>
setx PATH "%PATH%;C:\Users\janvi\AppData\Local\Programs\Ollama\" 
# replace the path with your ollama path
conda deactivate
conda activate <your_env_name>
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

@JANVI2411 commented on GitHub (Mar 8, 2025): It got resolved finally! Running the below commands and then restarting the Jupyter notebook ``` conda activate <your_env_name> setx PATH "%PATH%;C:\Users\janvi\AppData\Local\Programs\Ollama\" # replace the path with your ollama path conda deactivate ``` ``` conda activate <your_env_name> 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
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ollama/ollama-python#232