# On macOS (using Homebrew): [1]
$ brew install ollama
# ollama server (or just use the UI)
ollama serve
# check ollama running
ollama ps
# ping server to test (remove "stream": false to see tokens)
curl http://localhost:11434/api/generate -d '{ "model": "gpt-oss:20b", "prompt": "How are you today?", "stream": false}'
# get a model [1]
$ ollama pull gpt-oss:20b
# run model
ollama run gpt-oss:20b
----
# Create the virtual environment [2]
$ python3 -m venv env
# Activate the virtual environment [2]
$ source env/bin/activate
# install library [1]
$ pip install ollama
# create the requirments.txt [2]
$ pip freeze > requirements.txt
# OR install the requirements.txt
$ pip install -r requirements.txt
---
# simple script example [1]
import ollama
result = ollama.generate(model='gpt-oss:20b', prompt='Why is the sky blue?')
print(result['response'])
---
# Deactivate Virtual Environment [2]
$ deactivate
# Check its deactived
$ which python3
If it points inside your env/ folder, the venv is still active.
If it points to something like /usr/bin/python3 or your system-wide installation, it’s deactivated.
If you simply close the terminal (or shell session), the virtual environment is automatically deactivated because the environment variables only live in that shell process.
Running deactivate → clean way to exit the venv but keeps your shell open.
Closing the terminal → kills the whole session, so the venv is gone automatically.
Run
python3 simple_chatbot.py