Asked by Wilson Edwards
at 2025-02-07 00:06:18
Point:500 Replies:6 POST_ID:829297USER_ID:12108
Topic:
python3;centos;deepseek
Could not install ollama from python3 install ollama...so try alternative ,using python3 install openai , but easy example python script still not working, , the error is such as AttributeError: module 'ollama' has no attribute 'chat'
import ollam //or improt openairesponse = ollama.chat(model="deepseek-r1", messages=[ { "role":"user", "content":"how center a tag in a div tag by javascript" },])print(response["message"]["content"])
OR next example:
import os
import openai
openai.api_key = ("key")
openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "user", "content": "Hello!"}
]
)
print(completion.choices[0].message)
// Error AttributeError: module 'ollama' has no attribute 'ChatCompletion'
if use comand line ollama, it works
> ollama server //need enable port 127.0.0.1:11434
> ollam run deepseek-r1
>>>>"chat"
Any Advise ?
Try to list all module :
print(dir(ollama))
//No any moduel name, chat...
Error: Command '['/home/..../venv/bin/python3.x', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1
Reference: