## Module 1: Prepare to Run the Python Code

### Step 1. Open a terminal in IDE

+ Click [VS Code](${LAB:HTTPS_REVERSE_PROXY_URL}?next=${LAB:"/vscode/?folder=/root/tidb-lab-python"|urlencode} "VS Code") to open your lab IDE in the browser. It may take around 10 seconds for the web-based VS Code to be fully loaded.

+ Click `Yes, I trust the authors` in the popup window.

  ![90%](https://lab-static.pingcap.com/quick-demo/vscode-trust.jpg)

+ Click on `≡`, `Terminal`, then `New Terminal` to open a new terminal in the VS Code.

  ![90%](https://public-pingcap-innovation.s3.us-west-2.amazonaws.com/demo-405/405-open-terminal-0307.jpg)

### Step 2. Install Python dependencies

+ Run the following commands in the VS Code terminal to install the required dependencies.

  ```bash
  poetry install
  ```

  ```output
  Creating virtualenv tidb-lab-python-CQ_Jo6Zv-py3.11 in /root/.cache/pypoetry/virtualenvs
  Installing dependencies from lock file

  Package operations: 4 installs, 0 updates, 0 removals

    - Installing python-dotenv (1.0.1)
    - Installing dotenv (0.9.9)
    - Installing mysql-connector-python (9.2.0)
    - Installing pymysql (1.1.1)
  ```

### Step 3. Create the .env file

+ Create a `.env` file under folder `tidb-lab-python/`.

  ![90%](https://public-pingcap-innovation.s3.us-west-2.amazonaws.com/demo-405/405-new-env-0307.jpg)

+ Add the following content to the `.env` file and save it.

  ```properties
  TIDB_HOST=${LAB:SERVERLESS_CLUSTER_HOST}
  TIDB_PORT=${LAB:SERVERLESS_CLUSTER_PORT}
  TIDB_USER='${LAB:SERVERLESS_CLUSTER_USERNAME}'
  TIDB_PASSWORD='${LAB:SERVERLESS_CLUSTER_PASSWORD}'
  TIDB_DB_NAME=${LAB:SERVERLESS_CLUSTER_DATABASE_NAME}
  ```
