Python 3.12.2 Cannot import ollama #54

Closed
opened 2026-02-15 16:27:44 -05:00 by yindo · 8 comments
Owner

Originally created by @Ray0907 on GitHub (Mar 12, 2024).

I attempted to utilize the example, but encountered some errors as follows.
Python 3.12.2 (main, Feb 6 2024, 20:19:44) [Clang 15.0.0 (clang-1500.1.0.2.5)] on darwin

import ollama
from ollama import create
ImportError: cannot import name 'create' from partially initialized module 'ollama' (most likely due to a circular import) 
Originally created by @Ray0907 on GitHub (Mar 12, 2024). I attempted to utilize the example, but encountered some errors as follows. Python 3.12.2 (main, Feb 6 2024, 20:19:44) [Clang 15.0.0 (clang-1500.1.0.2.5)] on darwin ``` import ollama from ollama import create ImportError: cannot import name 'create' from partially initialized module 'ollama' (most likely due to a circular import) ```
yindo closed this issue 2026-02-15 16:27:44 -05:00
Author
Owner

@hanov commented on GitHub (Mar 28, 2024):

@Ray0907 rename your file from ollama.py to something different like test.py. It helped me. also keep in mind you need to install ollama with pip
pip3 install ollama

@hanov commented on GitHub (Mar 28, 2024): @Ray0907 rename your file from ollama.py to something different like test.py. It helped me. also keep in mind you need to install ollama with pip `pip3 install ollama`
Author
Owner

@ibrahim-string commented on GitHub (May 22, 2024):

The ollama python api takes much longer time than ollama command line.
why is that?

@ibrahim-string commented on GitHub (May 22, 2024): The ollama python api takes much longer time than ollama command line. why is that?
Author
Owner

@Albert337 commented on GitHub (May 28, 2024):

The ollama python api takes much longer time than ollama command line. why is that?

when i use ollama python api, i meet the eroor as following
image
What I'm thinking is that the LLM model hasn't been called yet, is there any suggestions?Thanks

@Albert337 commented on GitHub (May 28, 2024): > The ollama python api takes much longer time than ollama command line. why is that? when i use ollama python api, i meet the eroor as following ![image](https://github.com/ollama/ollama-python/assets/33714840/be87577a-c191-4df3-8b86-99214795119a) What I'm thinking is that the LLM model hasn't been called yet, is there any suggestions?Thanks
Author
Owner

@wyctorfogos commented on GitHub (Sep 21, 2024):

I've just uninstalled with 'pip uninstall ollama' and install again with 'pip3'. Also, I renamed my file and it works.

@wyctorfogos commented on GitHub (Sep 21, 2024): I've just uninstalled with 'pip uninstall ollama' and install again with 'pip3'. Also, I renamed my file and it works.
Author
Owner

@ahmetkarakaya commented on GitHub (Oct 7, 2024):

python. what a language it is. renaming works.

@ahmetkarakaya commented on GitHub (Oct 7, 2024): python. what a language it is. renaming works.
Author
Owner

@naitik2314 commented on GitHub (Jan 17, 2025):

Short answer: conda install conda-forge::ollama doesn't work, as resolved by wyctorfogos, uninstall using conda remove ollama (if installed using conda), then use pip3 install ollama

Long answer: I installed using conda first (as I prefer using conda venv for my projects), and after installation was successful, even running conda list shows ollama, import ollama didn't work (even after restart), unsinstalled using conda remove ollama, installed using pip3 install ollama, works like a charm.

@naitik2314 commented on GitHub (Jan 17, 2025): Short answer: conda install conda-forge::ollama doesn't work, as resolved by wyctorfogos, uninstall using conda remove ollama (if installed using conda), then use pip3 install ollama Long answer: I installed using conda first (as I prefer using conda venv for my projects), and after installation was successful, even running conda list shows ollama, import ollama didn't work (even after restart), unsinstalled using conda remove ollama, installed using pip3 install ollama, works like a charm.
Author
Owner

@ParthSareen commented on GitHub (Feb 13, 2025):

Closing this out - seems like it was a naming issue with filename. Python is such a fun language.

@ParthSareen commented on GitHub (Feb 13, 2025): Closing this out - seems like it was a naming issue with filename. Python is such a fun language.
Author
Owner

@cuicq commented on GitHub (Mar 27, 2025):

I finally got running

@cuicq commented on GitHub (Mar 27, 2025): I finally got running
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ollama/ollama-python#54