Read and Review Automation Anywhere Documentation

Automation 360

Close Contents

Contents

Open Contents

Python Script package

  • Updated: 7/16/2021
    • Automation 360 v.x
    • Build
    • RPA Workspace

Python Script package

The Python Script package contains actions that enable Python Script functions in a task.

Before you start

Ensure the following requirements are met before using the Python Script package:
  • The appropriate version of Python is installed on the device on which you want to execute the script.
    Note: Python versions 2.x and 3.x are supported.
  • The "PATH" environment variable is updated to the path of the Python folder.

    To verify if the Python environment variable is set correctly, enter Python in the command prompt. If it returns the Python version that is installed, the path environment is set up correctly.

Perform the following actions within the Python Script package as part of using the set of available actions:

  1. Open a Python Script file, or manually enter the script you want to run using the Open action. You must associate the details of the file or script you want to run with a session name.
  2. Run the script using the Execute function or the Execute script action.
    • If you uploaded a file containing the script, use the Execute script action.
    • If you manually input the script, use the Execute function action.
    You must use the same Python Script session name established in the Open action.
  3. Close the Python Script session after running the script.
Note: When you run a bot that contains Python Script actions, the script runs in the background.

To review the bot launcher logs, navigate to C:\ProgramData\AutomationAnywhere\BotRunner\Logs\<current month>\Bot_Launcher-<today's date>.log.zip. Each zipped folder contains a file with data on the code execution, which is useful for debugging.

Actions in the Python Script package

The Python Script package includes the following actions:
Note: The Open action must be the first action to use the Python Script in a task. These actions can run a Python Script on Windows, Linux, and UNIX-based devices.
Action Description
Close Closes the session.
Specify the same session name from the Open action.
Important: It is mandatory to close the session after the script is executed.
Execute function Executes a function within the Python Script.
  • In the Python session field, specify a session name. Use the same session name from the Open action.
  • Optional: Specify the function name to run and the arguments to pass to the function.

    This field supports Boolean, dictionary, list, number, or string variables.

    Note: The interface allows you to select only one argument. Use a list variable to concatenate multiple arguments into one variable.
  • Optional: In the Assign the output to variable field, specify the string variable.
For an example, see Example of using Python script to join a list.
Execute script Executes a script within the Python Script.
  • In the Python session field, specify a session name. Use the same session name from the Open action.
  • Optional: In the Assign the output to variable field, specify the string variable.

    If the bot executes the script successfully, this action returns the string True. Otherwise an error message appears.

For an example, see Create a PDF using Python script.
Open Opens a Python Script file.
  • In the Python session field, specify a session name. Use this same session name for other Python Script actions.
  • In the Python field, choose one of the following options:
    • In the Import existing file option, select an existing Python Script file.
      Note: If you are uploading a script from a file on your desktop, the file and any dependencies must be in a standalone folder. When you select a file for upload, all files and folders at the same folder level are uploaded.
    • In the Manual input option, enter the Python Script.
  • In the Python runtime version field, select 2 or 3 to specify the runtime version.
    Note: Select the runtime version based on the version of Python installed on the device.

More resources

Send Feedback