Python App Runner Guide

Python App Runner Guide

The Python App Runner template allows the easy setup and running of a range of Python apps, including in particular Discord bots. No app is configured in the same way, so the template has flexible options that can be used as required for a particular app.

This article gives guidance on the setup for some more common apps. It may be added to over time. It also outlines how to get the required Python installed on your system if you don’t have it already.

1. Installing Python

1.1 Linux

A version of Python is installed on most Linux systems by default. It might not however include all the required packages.

  • For Debian/Ubuntu and similar systems, make sure you have the pip and venv packages installed.

    For example, to install latest Python version available in the system repository, install:

    python3 python3-pip python3-venv

    Or for a specific version:

    python3.11 python3-pip python3.11-venv

  • For RHEL or similar systems, consult your system documentation. An example might be:

    python39 python3-devel

1.2 Windows

Installers can be downloaded from here.

Run the installer as Administrator, and select “Customize installation”. Make sure you select the option to install pip, and (under Advanced Options) the options to install Python for all users on the system and add it to the system’s environment variables. This will mean Python is installed in Program Files and is essential to ensuring it can be used by AMP.

2. Red Discord Bot

See here for detais of the bot, including the useful starting guide.

Make sure you have installed the required dependencies for your OS/distribution. You can’t use AMP’s Docker for this bot as the image does not include all dependencies (eg Java 17 for audio).

To install and set up the bot, configure the following in the App Runner Settings in your instance, then click Update:

  • App Download Type: select PyPI package

  • App Download Source: enter Red-DiscordBot

  • Run App Setup Command: enable

    Note: after updating the app the first time, disable this setting so that the bot configs are not reset on the next update

  • App Setup Command:

    • Windows: enter redbot-setup --no-prompt --instance-name amp_redbot --overwrite-existing-instance --data-path C:\AMPDatastore\Instances\<INSTANCE_NAME>\python-app-runner --backend json

      Change the drive letter and datastore path as needed, and include the instance name for <INSTANCE_NAME>

    • Linux: enter redbot-setup --no-prompt --instance-name amp_redbot --overwrite-existing-instance --data-path /home/amp/.ampdata/instances/<INSTANCE_NAME>/python-app-runner --backend json

      Change the datastore path as needed, and include the instance name for <INSTANCE_NAME>

  • Python Version: must be a version between 3.8 and 3.11 (or System default if your system default is one of those versions)

  • App Run Mode: select Python module

  • App Module Name: enter redbot

  • App Command Line Arguments: enter amp_redbot --token <BOT_DISCORD_TOKEN> --prefix ! --owner <OWNER_ID>

    Include your bot’s Discord token (as created following these instructions) for <BOT_DISCORD_TOKEN>, and your Discord ID for <OWNER_ID>