Appendix A. Setting Up Your Environment
This appendix provides the practical setup needed to work through the book’s examples without interruption. It introduces the core toolkit—Python, Jupyter Lab, PostgreSQL, an OpenAI account, and a few free data APIs—and explains that you do not need to install everything at once. Instead, the recommended approach is to get the basics in place first, then add extra tools as later chapters require them, with the companion repository supplying the book’s code, notebooks, sample data, and setup files.
The foundation of the workflow is a clean Python installation paired with a virtual environment, which keeps the book’s packages isolated from the rest of your system. After cloning the repository, readers install the shared dependencies and use Jupyter Lab as the main notebook interface for running examples. The appendix also introduces several AI coding companion options—such as ChatGPT, Cursor, Windsurf, and GitHub Copilot—while noting that the early chapters keep the assistant separate from the execution environment so learners can better understand how prompts become code.
Later sections focus on access and safety for external services. Readers create an OpenAI API key, install the current OpenAI Python SDK, and verify that the client can list models by reading the key from environment variables. The appendix also covers PostgreSQL and pgAdmin for SQL and pipeline work, including an optional Docker-based setup and loading the Pagila sample database. Finally, it explains how to manage secrets with environment variables or .env files, where to obtain NewsAPI and SerpAPI keys when needed, and how to run a quick smoke test to confirm that Python, libraries, notebooks, and credentials are all working properly.
A.11 Troubleshooting
"command not found: python" or wrong version. On macOS and Linux, use python3 and pip3. Confirm your virtual environment is active (your prompt should show (deai-venv)).
API key errors. Confirm the key is spelled correctly in .env, that you called load_dotenv() before reading it, and that your OpenAI account has billing set up and available credit.
Package installation fails, or a `ModuleNotFoundError` at import. Make sure your virtual environment is active, upgrade pip with pip install --upgrade pip, and confirm your Python version is compatible. If an import fails even after installing, confirm the package actually landed in this environment with pip show <package> (or list everything with pip list) — a common cause is installing into a different Python than the one running your notebook.
Jupyter can't find installed packages. Jupyter is probably running a different Python than your virtual environment. Install Jupyter inside the environment, register it as a kernel with python -m ipykernel install --user --name=deai-venv, and select that kernel.
PostgreSQL connection refused. Confirm the service is running (brew services list, systemctl status postgresql, or check Docker), that you are using port 5432, and that your username and password match what you set during installation.
Still stuck. Each chapter's README.md and setup/ folder in the repository include chapter-specific guidance, and you can open an issue on the GitHub repository for persistent problems.
With your environment in place, you are ready to follow along with every example in the book. Head back to whichever chapter you came from and pick up where you left off.
Learn AI Data Engineering ebook for free