liveBook · Manning

Chapter 15: Common errors and troubleshooting

What you will learn in chapter 15 of Build Applications with Local AI Models on a Mac

This introduction reframes programming errors as useful diagnostic information and emphasizes diagnosing and fixing them rather than avoiding them.

After this chapter you will be able to

What it builds on

Section by section

Introduction

This introduction reframes programming errors as useful diagnostic information and emphasizes diagnosing and fixing them rather than avoiding them.

Key terms: error messages, diagnose, fix

15.1 Common errors and solutions

Introduces the following six common errors as a field guide for faster troubleshooting.

15.1.1 Error: Model not found

Explains how to diagnose and fix Ollama’s “model not found” error by checking whether the model is downloaded and whether its name and tag are correct.

Key terms: model not found, ollama pull, ollama list, name:tag, latest, model tag

15.1.2 Error: Connection refused

This section explains why Python may report a connection error with Ollama and how to check and restart the local service.

Key terms: connection error, Ollama server, service, port 11434, ollama serve, Activity Monitor, http://localhost:11434, Ollama desktop app

15.1.3 Error: Out of memory

This section explains how to recognize when a local model exceeds available RAM and how to reduce memory pressure.

Key terms: available RAM, memory, LLMs, available memory, loaded models, memory pressure, RAM

15.1.4 Error: Port already in use

Explains why Ollama reports that port 11434 is already in use and how to decide whether to reuse or stop the process occupying it.

Key terms: port 11434, Ollama server, port already in use, process ID (PID), force-kill, existing Ollama instance

15.1.5 Error: Streamlit ModuleNotFoundError

This subsection explains why a Streamlit import error often comes from using the wrong Python environment and how to check and correct it.

Key terms: Streamlit, ModuleNotFoundError, virtual environment, Python interpreter, (venv)

15.1.6 Error: Python version problems

This section explains how to identify and fix Python-version problems that prevent Streamlit or the Ollama Python library from working.

Key terms: Python version, Python executable, virtual environment, Python 3.9 or later

15.2 Reading error messages effectively

This section teaches a three-step way to read a Python traceback to identify an error and trace how the program reached it.

Key terms: Python traceback, exception, error type, call chain

15.3 Debugging techniques

This section introduces using an LLM to suggest a likely cause of an error while protecting sensitive information and verifying its suggestions yourself.

Key terms: LLM, traceback, hypothesis, cloud model, local Ollama model

15.3.1 Using try/except blocks

This section shows how try/except blocks let a program respond helpfully to errors instead of crashing.

Key terms: try/except block, Exception, raw traceback

15.3.2 Step-by-step verification

This subsection teaches how to locate a chatbot startup failure by checking prerequisites separately rather than treating the pipeline as one failing step.

Key terms: chatbot pipeline, imports, Ollama server connection, model availability, Streamlit startup, debug_test.py

15.3.3 Print debugging

This section introduces print debugging as a way to inspect variable values and see which parts of a program run, with a Streamlit-specific tip.

Key terms: print debugging, print statements, st.write()

15.3.4 Logging

This subsection explains why Python logging is useful for ongoing projects and how to change its detail level between debugging and production.

Key terms: logging module, logging level, DEBUG, WARNING, ERROR, production

15.4 The troubleshooting roadmap

This section gives two ways to start troubleshooting: categorize a problem with a flowchart and inspect issues reported by VS Code.

Key terms: flowchart, problem category, VS Code, Problems panel

15.4.1 Four levels of troubleshooting

This section gives an ordered four-level checklist for narrowing down problems in a local AI application.

Key terms: environment checks, Ollama checks, code checks, Streamlit-specific checks

15.4.2 A note on asking for help

The section shows how to ask for useful debugging help and how explaining code aloud can reveal a problem before asking.

Key terms: minimal reproducible example, full error message, environment, rubber duck debugging

15.5 Exercises

15.6 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 14: Offline LLMs and their benefits Chapter 16: Advancing to RAG, Web UI, and fine-tuning →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.