Overview

Appendix A. Setting up your development environment

This appendix explains how to prepare a stable, isolated Python setup for the book’s financial AI projects so that complex dependencies do not conflict with other software on your system. It recommends using Python 3.12.3 or a newer 3.12 release, then creating a dedicated environment with either the built-in venv module or conda. The goal is to match the tested development conditions as closely as possible before working with the code.

After the environment is created, the text outlines installing a carefully pinned set of libraries through a requirements.txt file so the modeling, data, visualization, deep learning, and generative AI examples behave consistently. It also points out several platform-specific or package-specific considerations, such as PyTorch GPU setup for CUDA users, OpenMP support on macOS for xgboost and lightgbm, extra system dependencies for TA-Lib, and the recommendation to keep Apache Airflow in a separate environment because of its heavier dependency tree.

The appendix also emphasizes secure handling of credentials and practical project organization. It shows how to store API keys in a hidden .env file loaded with python-dotenv, reminds readers to add that file to .gitignore, and explains that the book’s code and datasets are available in a Git LFS-backed repository that should be cloned with the proper tooling installed. Finally, it suggests verifying the installation by importing the core libraries and printing their versions; if that check succeeds, the environment is ready for the book’s models, notebooks, and agents.

FAQ

Why should I use an isolated virtual environment for this book’s code?Using an isolated virtual environment keeps the book’s packages separate from your system Python and other projects, reducing version conflicts and making your setup more reproducible.
Which Python version is recommended for the examples in this appendix?Python 3.12 is recommended, preferably Python 3.12.3 or any newer 3.12.x release, because the book’s code and dependencies were developed and tested with that version.
Should I use venv or conda to create my environment?Both work, but venv is recommended for most users. If you already prefer Anaconda or Miniconda, conda is an acceptable alternative.
How do I create and activate a virtual environment with venv?Run python -m venv finai_env, then activate it with source finai_env/bin/activate on macOS/Linux or finai_env\Scripts\activate on Windows.
How do I create the environment with conda?Create it with conda create -n finai_env python=3.12.3 and activate it with conda activate finai_env.
How do I install the book’s required libraries?Create a requirements.txt file in your project root with the pinned package versions, then run pip install -r requirements.txt inside the activated environment.
What should I do if a pinned dependency fails to install on my platform?Install the latest compatible release for that package and use the updated lock file in the book’s GitHub repository, since all versions were tested together on Python 3.12.
How should I manage API keys and other secrets for the book’s projects?Store them in a hidden .env file and load them with python-dotenv, rather than hardcoding them into scripts. Also add .env to .gitignore.
Why do I need Git LFS for the book’s GitHub repository?Several chapters include large data files, so Git LFS is needed to download the real data instead of small pointer files when cloning the repository.
How can I verify that my installation is working correctly?Run the provided import check for core libraries like pandas, numpy, scikit-learn, xgboost, lightgbm, tensorflow, torch, evidently, and openai. If each library prints a version number, the environment is set up correctly.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Financial AI in Practice ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Financial AI in Practice ebook for free