Most “chat with dataframe” tutorials are quietly broken. They show you the v2 SmartDataframe API, tell you to set PANDASAI_API_KEY, and assume any Python version works. Copy-paste their code against PandasAI 3.0.0 today and none of it runs – the class doesn’t exist anymore, the env var was renamed, and Python 3.12 is explicitly blocked.
This guide skips the marketing and walks through what an actual chat with dataframe deployment looks like on the current release: PandasAI 3.0.0, published Oct 7, 2025. Commands you can paste. Errors you’ll probably hit. The migration trap nobody warns about.
What you’re actually installing
PandasAI wraps an LLM around your dataframes so you can ask questions in plain English. Per the official GitHub repo: “Chat with your database or your datalake (SQL, CSV, parquet). PandasAI makes data analysis conversational using LLMs and RAG.” It’s MIT-licensed – except the pandasai/ee directory, which carries a separate enterprise license.
Before you commit: v3 is a different library than v2 in everything but the package name. New API surface, new env vars, new LLM integration model. If you’ve used it before, treat this as a fresh install – not an upgrade.
The version trap
The single most common install failure is Python version. PyPI metadata for pandasai 3.0.0 requires Python <3.12, >=3.8 – so Python 3.12 and 3.13 are blocked as of the Oct 2025 release.
| Requirement | Supported range | Recommended |
|---|---|---|
| Python | 3.8 – 3.11 | 3.11 |
| Build tools | – | Rust + C compiler on Windows/Linux for source builds |
| LLM access | OpenAI / Anthropic / local via LiteLLM | Any OpenAI-compatible model (e.g., gpt-4.1-mini as of Oct 2025) |
The Rust requirement isn’t documented prominently. When a prebuilt wheel isn’t available for your platform, the sqlglotrs dependency tries to compile from source. That fails with: “Cargo, the Rust package manager, is not installed or is not on PATH… Install it through the system’s package manager or via rustup.rs.” (GitHub issue #1692.)
Installation: the path that actually works
Use a fresh virtual environment. Don’t install into your daily-driver env – the pandas downgrade trap covered in the errors section will break unrelated notebooks.
# Create isolated env on Python 3.11 (NOT 3.12+)
python3.11 -m venv .venv
source .venv/bin/activate # Windows: .venvScriptsactivate
# Install PandasAI + the LiteLLM bridge for OpenAI/Anthropic/etc.
pip install "pandasai==3.0.0"
pip install pandasai-litellm
The official docs actually recommend Poetry as the primary method (poetry add pandasai), with pip as the fallback. Poetry is genuinely better here because it locks the dependency tree – and pandasai’s tree is fragile enough that minor resolver differences produce different outcomes on the same machine.
For the Docker sandbox (safer code execution), add it now:
pip install pandasai-docker
First-time configuration
Two things have to be true before df.chat() works: an LLM is wired in, and the API key env var uses the new name.
The env var rename nobody catches: v3 changed
PANDASAI_API_KEYtoPANDABI_API_KEY(andPANDASAI_API_URLtoPANDABI_API_URL). PR #1511 in the v3 changelog is where this landed. If you copied any 2024 tutorial, your key is being silently ignored. One missing letter – you’ll only catch it by reading release notes.
Minimum viable config:
import pandasai as pai
from pandasai_litellm.litellm import LiteLLM
llm = LiteLLM(model="gpt-4.1-mini", api_key="sk-...")
pai.config.set({"llm": llm})
df = pai.read_csv("data/sales.csv")
print(df.chat("Which region grew fastest year over year?"))
The structure is a complete break from v2. Turns out the old SmartDataframe(df, config={"llm": llm}) pattern – where you imported from pandasai.llm.openai – doesn’t exist at all in v3. Now you import pandasai as pai, initialize LiteLLM separately, set config globally, then call df.chat("...") on whatever pai.read_csv returned.
Verify the install
Don’t trust pip’s success message – verify with an actual call.
- Check the version:
python -c "import pandasai; print(pandasai.__version__)"should print3.0.0or higher. - Smoke-test without an LLM:
python -c "import pandasai as pai; print(pai.DataFrame({'x':[1,2,3]}))"– if this import alone fails, you have a dependency conflict. - Full round-trip: run the snippet above with a tiny CSV and a simple question. String answer back? LLM wiring is correct.
Five errors, five specific causes
Generic “try reinstalling” advice doesn’t help here. Each failure mode has a specific root cause.
- scipy build fails with “Unsupported Python version 3.12.4” – pandasai 3.0.0 depends on scipy 1.10.1, and that scipy version’s meson build refuses Python 3.12 (GitHub issue #1837). No flag bypasses this. Downgrade to Python 3.11.
- LNK1120 linker errors on Windows – on Windows with Python 3.12, pip can fail building C-extension wheels even after installing Visual C++ Build Tools (issue #1221). Same root cause: switch to Python 3.11.
- Cargo not found – install Rust via rustup.rs, then retry. Happens when no prebuilt
sqlglotrswheel exists for your platform. - ModuleNotFoundError after a successful install – almost always pip installed into a different Python than the one running your script. Run
which pythonandwhich pipand confirm they match. - Existing pandas got downgraded – installing pandasai into a pre-existing env has been reported to downgrade pandas (e.g., from 2.3.0 to 1.5.3), which then breaks unrelated code like reading Excel files (GitHub issue #1756). Always use a fresh venv.
Upgrading from v2
Not just a version bump. Your imports change, your env vars change, and your SmartDataframe code stops working. The old v2 pattern – from pandasai import SmartDataframe followed by df = SmartDataframe(df, config={"llm": llm}) – is gone entirely in v3.
Pragmatic migration path:
- Pin the old version in your existing project:
pip install "pandasai<3.0"if you can’t migrate yet. - Start a fresh venv for v3 and rewrite the call sites – there usually aren’t many.
- Rename env vars:
PANDASAI_API_KEY→PANDABI_API_KEY. - Replace
SmartDataframe(df, ...)withpai.DataFrame(...)+pai.config.set({"llm": llm}).
To uninstall cleanly: pip uninstall pandasai pandasai-litellm pandasai-docker removes the libraries, but chart exports may remain in ./pandasai/exports/charts – delete that folder manually if you want a clean slate.
Is this actually ready for production?
Honest answer: not quite – at least not without guardrails. The library executes LLM-generated Python against your data. The official answer for safety is the Docker sandbox: wrap calls with DockerSandbox().start() and pass sandbox=sandbox to pai.chat. That mitigates the obvious risk of running untrusted code, but it also means production needs Docker running alongside your app.
For internal analyst tools, notebooks, and prototypes, it’s solid. Customer-facing features over sensitive data are a different question – you’d want the sandbox plus a strict allow-list of operations, and possibly self-hosting the LLM via LiteLLM’s local model support rather than shipping rows to a third-party API. Whether that tradeoff is worth it depends entirely on your data classification requirements.
FAQ
Can I use PandasAI with a local LLM instead of OpenAI?
Yes. LiteLLM supports Ollama, vLLM, and other local backends – swap the model string and point it at your local endpoint. No PandasAI code changes needed.
Why does PandasAI keep downgrading my pandas version?
Its dependency spec pins a narrower pandas range than the latest pandas release. This has been filed repeatedly on GitHub – issue #1756 is the most detailed report. The only fix that actually holds is isolating pandasai in its own venv. Don’t try force-upgrading pandas inside a pandasai env. It installs without errors, then pandasai’s own modules crash at import time when they hit a pandas API that was removed in 2.x – which is worse than the original downgrade problem.
Does pip install pandasai work on Python 3.13?
No. As of the 3.0.0 release (Oct 7, 2025), the PyPI metadata hard-caps Python at <3.12. Check the releases page before upgrading your interpreter – support may expand in a later patch.
Next step: spin up a Python 3.11 venv right now, install pandasai 3.0.0 plus pandasai-litellm, and run the verify snippet against a 100-row CSV from one of your real projects. If the first df.chat() returns something useful, you have a working deployment in under 10 minutes. If it doesn’t, you’ll know exactly which of the five errors above to chase.