Skip to content

Installing Python libraries

The Python Script component lets you import modules from any Python library. To do this, you need to upload the packages to an Amazon S3 bucket or Azure Blob Storage location accessible to the agent, as described below.


Install the Python package

  1. Install the library on a local drive, using the following command:

    pip install --target=<local_file_path> <package>
    

    Where <local_file_path> is a temporary location you will use to hold the package, and <package> is the package name.

    For example, to install the requests library you could use:

    pip install --target=/Users/matillionuser/Desktop requests
    

    This command will unpack the package and create a folder that contains all the necessary Python scripts and other files that make up the Python library.

  2. Copy the entire folder containing the unpacked files into an S3 bucket (for AWS-hosted agents) or Azure Blob Storage container (for Azure-hosted agents) that is accessible to the agent.

    Note

    At this point, you can delete the package from your local drive, if you wish.

  3. The IAM role tied to the agent must have certain user permissions in order to access the contents of the S3 bucket. Read Storing external files for details of these permissions.

  4. Set an agent parameter EXTENSION_LIBRARY_LOCATION, with the value being the storage location where the Python libraries reside, for example s3://my-additional-libraries. Read Optional agent parameters for details.

Upon completion, the Python Script component can reference and access your installed libraries via your script.