Model to Machine / Free tutorials

WINDOWS + PYTHON / BEGINNER GUIDE

How to check your local Ollama setup on Windows with Python

Before building an AI assistant, verify the local model server. A common beginner problem is confusing a working Python installation with a running model server. This guide checks the connection without sending a prompt, downloading another model or requiring a paid API key.

1. Install and open Ollama

Get the Windows installer from Ollama's official website. Open the app. For the Python exercise, install Python 3 from python.org if needed. Installation and model downloads require an internet connection.

2. Verify the server in PowerShell

Open PowerShell and run:

ollama list

This lists installed models. To check whether the same local HTTP service responds:

Invoke-RestMethod http://127.0.0.1:11434/api/tags

The response includes a models collection. An empty collection means the server responds but no model is installed. A connection refusal means the server is not reachable; open Ollama and try again. If another service occupies port 11434, identify it before changing settings.

3. Read installed model names in Python

Save the following as check_models.py. It uses the standard library, so no Python packages are required.

import json
from urllib.request import urlopen

with urlopen("http://127.0.0.1:11434/api/tags", timeout=5) as response:
    data = json.load(response)

models = data.get("models", [])
if not models:
    print("No local models installed yet.")
for model in models:
    print(model["name"])

Run:

py check_models.py

Each installed model name appears on its own line. If Python reports a connection error, repeat step 2. If Windows cannot find py, try python check_models.py or review your Python installation.

4. Run a first prompt

Choose a model name from the list and substitute it for MODEL_NAME:

ollama run MODEL_NAME

Type a question in the interactive terminal. Choose a small model compatible with your hardware if none is installed. The Ollama model library lists available models. Larger models require more memory and might be slow. Do not expose the local service to the internet for this exercise.

What you have learned

Ollama runs the model server. Python communicates with the server through HTTP. Your future assistant will send conversation messages to the model and render the response. A successful model-list request checks connectivity, not inference performance. The model-list endpoint was tested on a Windows PC; individual hardware and model behavior vary.

Reference: Ollama list models API.