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
andvenv
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
- the option to install py launcher for all users
- (under Advanced Options) the option to install Python for all users on the system
- (under Advanced Options) the option to add Python 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.
If you have an existing installation you can run the installer as Administrator and select “Modify” to do the above.
2. Red Discord Bot
See here for details of the bot, including the useful starting guide.
Make sure you have installed the required dependencies for your OS/distribution. Or, if you are using AMP’s Docker for this bot, you must add the packages openjdk-17-jre-headless
and nano
to the Container Packages under Container Settings for the instance.
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:
-
Instance NOT in Docker: 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>
-
Instance in Docker: enter
redbot-setup --no-prompt --instance-name amp_redbot --overwrite-existing-instance --data-path /AMP/python-app-runner --backend json
-
-
-
Python Version: must be a version between 3.8 and 3.11 (or
System default
if your system default is one of those versions). If using AMP’s Docker, leave it onSystem default
) -
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>
3. Palworld Palbot
See here for details of the bot, as well as the wiki for details on configuring it.
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
Git repo
- App Download Source: enter
https://github.com/dkoz/palworld-palbot.git
- Python Version: must be version 3.10 or higher (or
System default
if your system default is one of those versions) - Python Packages Install Method: select
Requirements.txt file
- App Run Mode: select
Python script
- App Module Name: enter
main.py
Once installed, using AMP’s File Manager rename .env.example
to .env
and config.json.example
to config.json
and edit according to the wiki instructions, including to specify your Discord bot token and Steam API key, as well as settings for your Palworld servers.
See this troubleshooting page if you run into issues.