Learning · · 4 min read
Setting up a Python AI Development Environment: My Simple Guide
I walk through how I set up a cheap, reproducible Python AI development environment using VS Code, Claude Code, Supabase, and Gemini. Perfect for beginners in Pundri or anywhere.
When I first decided to build AI‑powered chatbots from my small room in Pundri, the biggest hurdle was simply getting a reliable development environment up and running. In this post I’ll show you exactly how I **setup python ai development environment** with free tools, so you can start coding without hunting down endless tutorials.
Why a clean environment matters
A messy setup quickly becomes a rabbit hole: version conflicts, missing libraries, and the dreaded "it works on my machine" problem. By keeping everything in a single folder, using virtual environments, and pinning versions, you spend more time building and less time debugging. I learned this the hard way while adding email notifications to my Python chatbot.
Tools I rely on
- VS Code – lightweight editor with great extensions for Python and AI.
- Claude Code – AI‑assisted coding assistant that helps you write and refactor code.
- Supabase – free backend for auth, storage, and edge functions.
- Gemini API – Google’s generative model for chat and embeddings.
- Git – version control, even if you push only to a private repo.
Step‑by‑step: creating the environment
Below are the exact commands I run on a fresh Ubuntu‑based laptop. If you’re on Windows, the same commands work in PowerShell or Git Bash.
# 1. Install Python 3.11 (or the latest stable version)
sudo apt update && sudo apt install -y python3 python3-venv python3-pip
# 2. Create a project folder
mkdir ~/ai‑chatbot && cd ~/ai‑chatbot
# 3. Initialise a virtual environment
python3 -m venv .venv
source .venv/bin/activate
# 4. Upgrade pip and install core libraries
pip install --upgrade pip
pip install "langchain[all]" supabase python‑dotenv requests
# 5. Add a .env file for secrets (Supabase URL, anon key, Gemini API key)
cat <<EOF > .env
SUPABASE_URL=your‑supabase‑url
SUPABASE_ANON_KEY=your‑anon‑key
GEMINI_API_KEY=your‑gemini‑key
EOF
The .env file keeps your keys out of source control. I use the **dotenv** Python package to load them at runtime.
from dotenv import load_dotenv
import os
load_dotenv()
SUPABASE_URL = os.getenv("SUPABASE_URL")
GEMINI_API_KEY = os.getenv("GEMINI_API_KEY")
Integrating Claude Code in VS Code
Claude Code works as a VS Code extension. After installing it from the marketplace, I set the API key in the extension settings. The real magic is the "inline suggestion" feature – as I type a function signature, Claude completes the docstring and even suggests error handling. It’s not a substitute for understanding, but it speeds up repetitive boilerplate.
Connecting to Supabase
Supabase provides a Postgres database, storage buckets, and edge functions – all for free on the hobby tier. I usually start with the Python client that wraps the REST API.
from supabase import create_client
supabase = create_client(
SUPABASE_URL,
os.getenv("SUPABASE_ANON_KEY")
)
# Example: Insert a new user record
response = supabase.table("users").insert({"email": "test@example.com"}).execute()
print(response.data)
If you need authentication later, I covered that in my post about adding Supabase Auth to a Python chatbot. You can follow a similar pattern, just swapping the client to use the service role key for admin tasks.
Read more about that here: adding Supabase authentication to my Python chatbot.
Calling the Gemini API
Gemini’s REST endpoint is straightforward. I wrap it in a small helper so I can reuse it for both chat completions and embeddings.
import requests
def gemini_chat(messages, model="gemini-1.5-flash"):
url = f"https://generativelanguage.googleapis.com/v1beta/models/{model}:generateMessage"
payload = {"messages": messages}
headers = {"x-goog-api-key": GEMINI_API_KEY}
response = requests.post(url, json=payload, headers=headers)
response.raise_for_status()
return response.json()["candidates"][0]["content"]["parts"][0]["text"]
The function returns plain text, which I then feed into my chatbot logic. If you need vector embeddings for similarity search, check my guide on adding vector search with Supabase.
You can see that walkthrough here: adding vector search to my Python chatbot with Supabase.
Putting it all together: a minimal chatbot script
def chat_loop():
print("AI Assistant (type 'exit' to quit)")
while True:
user_msg = input("You: ")
if user_msg.lower() in {"exit", "quit"}:
break
# Store conversation in Supabase (optional)
supabase.table("messages").insert({
"role": "user",
"content": user_msg
}).execute()
# Get AI response
response = gemini_chat([{"role": "user", "content": user_msg}])
print(f"AI: {response}")
# Save AI reply
supabase.table("messages").insert({
"role": "assistant",
"content": response
}).execute()
if __name__ == "__main__":
chat_loop()
That’s it – a fully functional chatbot that talks to Gemini, stores each turn in Supabase, and runs locally. From here I added email notifications, voice input, and a web UI in later projects.
Tips for keeping the environment clean
- Commit your **requirements.txt** (generated with `pip freeze > requirements.txt`). This makes it easy for anyone else to recreate the environment.
- Run `pre-commit` hooks for formatting (Black) and linting (Flake8). It catches small errors before they become bugs.
- Periodically prune unused packages: `pip uninstall -y $(pip freeze | grep -v "^-e" | awk -F== '{print $1}')` after checking the list.
- Store secrets only in `.env` and add that file to `.gitignore`.
What I still need to learn
I haven’t yet explored containerising this setup with Docker, nor have I tried using a cloud‑based IDE like GitHub Codespaces. Those are on my to‑do list, and I expect they’ll make collaboration easier once I start sharing code with friends in Kaithal.
If you’re curious about my other projects, take a look at my projects for a quick overview.
Takeaway
A reproducible Python AI development environment can be built in under an hour using free tools. By separating concerns – editor, AI assistant, backend, and secrets – you stay in control, avoid version chaos, and can iterate quickly on new ideas.
Frequently asked questions
Do I need a paid account for Supabase or Gemini?
No. Both Supabase and Gemini offer generous free tiers that are sufficient for small experiments and learning projects.
Can I use this setup on Windows?
Yes. The same commands work in PowerShell or Git Bash. Just ensure Python 3.11 is installed and use `venv` to create the virtual environment.
Why should I use a virtual environment?
A virtual environment isolates your project’s dependencies, preventing conflicts with other Python projects on the same machine.
Is Claude Code necessary for building the chatbot?
Claude Code is optional but helpful for generating boilerplate and suggestions. You can replace it with any code editor you prefer.