appendix-d

Appendix D. Troubleshooting Common Errors

 

When an example does not work, the cause is usually one of a small number of recurring issues: a key that is not set, a package that is not installed, an API that changed, or data that is shaped differently than the code expects. This appendix groups the errors you are most likely to hit by category, with the symptom, the usual cause, and the fix. Where a full setup is involved, it points you to Appendix A.

D.1 Environment and setup

Table D.1 Environment errors
Symptom
Cause
Fix
command not found: python
Python isn't installed, or your system only exposes it as python3
First confirm Python 3.8+ is actually installed (Appendix A); if it is, the command is usually python3 and pip3 (Mac/Linux). Confirm your virtual environment is active (prompt shows (venv))
ModuleNotFoundError: No module named 'X'
Package not installed, or the wrong Python is active
Activate the venv, then pip install -r requirements.txt. Confirm with pip list
Jupyter can't find an installed package
Jupyter is running a different Python than your venv
Install Jupyter inside the venv and register a kernel: python -m ipykernel install --user --name=venv, then pick that kernel
pip install fails or is slow
Old pip, wrong Python version, or a slow network connection
pip install --upgrade pip; confirm Python 3.8+

D.2 API keys and authentication

D.3 OpenAI API errors

D.4 Web scraping and HTTP

D.5 Data and pandas

D.6 D.6 PostgreSQL

D.7 When you are still stuck