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, butvenv 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?
Runpython -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 withconda 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 arequirements.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.
Financial AI in Practice ebook for free