Search code examples
pythonpython-3.xpipollamahaystack

Using Haystack and Ollama . ModuleNotFoundError: No module named 'ollama'


I'm running an example from the haystack website here

I have used poetry to add ollama-haystack

I am running the following code using Python 3.12.3 on WSL2 ubuntu 24.04

from haystack_integrations.components.embedders.ollama import OllamaTextEmbedder

embedder = OllamaTextEmbedder()

result = embedder.run(text="What do llamas say once you have thanked them? No probllama!")

print(result['embedding'])

I am getting an error:

 File "/home/../.venv/lib/python3.12/site-packages/haystack_integrations/components/embedders/ollama/document_embedder.py", line 6, in <module>
    from ollama import Client
ModuleNotFoundError: No module named 'ollama'

My python is a bit rusty so apologies if the error is obvious.


Solution

  • You need to install module on WSL2 ubuntu 24.04

    pip install ollama-haystack
    

    https://pypi.org/project/ollama-haystack/