What Are the Dependencies for AI Berkshire? A Complete Python Requirements Guide
The AI Berkshire project requires only Python 3 and the Playwright library, with all other functionality implemented using the standard library.
AI Berkshire is a Python-based research toolkit for financial analysis and automated data collection. According to the source code in the xbtlin/ai-berkshire repository, the project maintains a minimal dependency footprint by leveraging built-in Python modules for most operations. The only external package required is Playwright, which powers the asynchronous web scraping capabilities.
Core Dependencies for AI Berkshire
Python Standard Library Modules
The bulk of AI Berkshire's functionality relies entirely on Python's built-in standard library. The codebase imports the following modules across its tool suite:
- File and system operations:
os,pathlib,subprocess,sys - Data formats:
json,csv - Date and time handling:
datetime,decimal(for precise financial arithmetic) - Networking and web:
urllib.request,asyncio - Utilities:
argparse,collections.OrderedDict,random,re
These imports appear throughout the repository, including in tools/stock_screener.py (lines 20-25), tools/report_audit.py (lines 24-31), tools/financial_rigor.py (lines 18-22), and tools/ashare_data.py (lines 16-21).
Third-Party Requirements
The only non-standard dependency identified in the source code is Playwright. This library is imported specifically in tools/xueqiu_scraper.py at lines 38-39 to provide headless browser automation for fetching data from Chinese financial portals.
How Playwright Is Used in AI Berkshire
The tools/xueqiu_scraper.py file implements asynchronous web scraping using Playwright's async API. The following pattern demonstrates how the browser automation is initialized:
from playwright.async_api import async_playwright
async def fetch_page(url: str) -> str:
async with async_playwright() as p:
browser = await p.chromium.launch(headless=True)
page = await browser.new_page()
await page.goto(url)
content = await page.content()
await browser.close()
return content
This implementation allows the project to scrape dynamic content from Xueqiu and other JavaScript-heavy financial websites without requiring additional HTTP libraries like requests or httpx.
Standard Library Implementation Details
AI Berkshire demonstrates extensive use of standard library patterns for data processing and system integration.
JSON Configuration Handling
In tools/stock_screener.py, the project uses built-in json modules to load watchlists and configuration files:
import json, os
from datetime import datetime, timedelta
def load_watchlist(path: str = "data/watchlist.json"):
with open(path, encoding="utf-8") as f:
return json.load(f)
CSV and Subprocess Operations
The tools/morningstar_fair_value.py and tools/ashare_data.py files utilize csv for reading financial data and subprocess.run for executing external commands and data pipelines. These implementations avoid heavier data science libraries like pandas or numpy, keeping the installation requirements lightweight.
Verifying Your Installation
To run the AI Berkshire tools locally, install the single external dependency using pip:
pip install playwright
playwright install
The playwright install command downloads the necessary browser binaries (Chromium, Firefox, or WebKit) required for the scraping functionality in tools/xueqiu_scraper.py.
Summary
- AI Berkshire dependencies are minimal by design, requiring only Python 3 and Playwright.
- Standard library modules handle JSON parsing, CSV processing, date arithmetic, and system calls across
tools/stock_screener.py,tools/financial_rigor.py, andtools/ashare_data.py. - Playwright is the sole third-party requirement, imported in
tools/xueqiu_scraper.pyfor asynchronous web scraping. - No pandas, numpy, or requests dependencies exist in the codebase, keeping the project lightweight and installable without complex scientific computing stacks.
Frequently Asked Questions
Does AI Berkshire require pandas or numpy?
No. According to the source code analysis, the project does not import pandas, numpy, or similar data science libraries. All data processing is handled using the standard library's csv, json, and decimal modules, along with native Python data structures.
What version of Python is required for AI Berkshire?
The codebase utilizes modern Python 3 features including asynchronous/await syntax (asyncio) and type hints. While the repository does not specify a minimum version in the provided analysis, the use of pathlib and async_playwright suggests Python 3.7 or higher is required for full compatibility.
How do I install the Playwright dependency for AI Berkshire?
Install Playwright via pip using pip install playwright, then run playwright install to download the browser binaries. This setup is necessary only if you intend to use the web scraping functionality in tools/xueqiu_scraper.py; other tools in the repository function without it.
Are there any optional dependencies in AI Berkshire?
Based on the source code analysis, there are no documented optional dependencies. All tools function with the standard library alone, except for the Xueqiu scraper which strictly requires Playwright. No extras or conditional imports for additional libraries were found in tools/report_audit.py, scripts/sync-codex-skills.py, or other examined files.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →