Setting up Browser Use AI Agent locally with Python & WSL | Alpha | PandaiTech

Setting up Browser Use AI Agent locally with Python & WSL

A complete guide to terminal commands for cloning the repository, setting up virtual environments, installing dependencies, and configuring API keys before launching the Web UI.

Learning Timeline
Key Insights

The Importance of Virtual Environments

Always use a virtual environment (venv) to ensure that the library installations for this AI project do not interfere with or break existing Python libraries on your system.

Playwright's Role in Browser Use

Playwright is a critical component that enables LLMs (like GPT-4 or Claude) to simulate clicks, typing, and reading website content as if performed by a human.

API Key Security Tips

If you are sharing your screen during setup, make sure to revoke your API key once finished to prevent unauthorized credit usage by others.
Step by Step

Setting Up the Terminal and Python Environment

  1. Launch the Ubuntu terminal on WSL (version 22.04 is recommended).
  2. Check your Python version by typing 'python3 --version' to ensure you are using Python 3.11.
  3. If you're using 'pyenv', set your Python version globally with the command 'pyenv global 3.11'.
  4. Clone the project repository by typing 'git clone [URL-Repository-Web-UI]'.
  5. Navigate into the project directory using the command 'cd web-ui'.

Setting Up the Virtual Environment and Dependencies

  1. Install the virtual environment module if you haven't already with the command 'pip install virtualenv'.
  2. Create a new virtual environment by typing 'python3 -m venv .venv'.
  3. Activate the virtual environment with the command 'source .venv/bin/activate'.
  4. Install all required project libraries with 'pip install -r requirements.txt'.
  5. Install Playwright to allow the AI to control the browser using the command 'playwright install'.

Configuring API Keys and Launching the Web UI

  1. Copy the environment example file to an active file with the command 'cp .env.example .env'.
  2. Open the file for editing using a text editor by typing 'nano .env'.
  3. Enter your OpenAI or Anthropic API Key in the provided fields.
  4. Enter the AI server's IP address if you are using your own server (such as Terry).
  5. Save your settings by pressing 'Ctrl + X', then press 'Y' and 'Enter'.
  6. Launch the application with the command 'python web_ui.py'.
  7. Open your browser and access the application at 'http://localhost:7788'.

More from Local AI & Open Source Deployment

View All