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

When installing Python libraries for Hybrid SaaS agents, make sure the libraries are compiled for the correct platform. Hybrid SaaS agents run on Linux (Ubuntu).

If you install packages on a different operating system (for example, macOS or Windows), pip may fetch incompatible binaries that cannot run inside the agent. This often causes runtime errors.

Note

Ensure the Python version you are using to download matches (or is close to) the agent runtime version. As of writing, the agent runs Python 3.10.12. This will ensure you fetch compatible versions of the required libraries.

  1. Create a directory on your local machine to store the downloaded libraries:

    mkdir python_libs
    
  2. Download the required libraries using pip with the --platform and --only-binary flags:

    python3 -m pip install --target=./python_libs --platform=manylinux2014_x86_64 --only-binary=:all: scipy pandas numpy
    

    Command Breakdown :

    • --target=./python_libs: Specifies the installation directory.
    • --platform=manylinux2014_x86_64: This flag is critical. It directs pip to download the package for the specified Linux platform and architecture, matching the agent's environment.
    • --only-binary=:all:: Ensures that pip downloads pre-compiled binary wheels instead of attempting to build from source.
  3. After the command completes, the ./python_libs folder will contain the specified libraries and all their dependencies, compiled for the correct platform.

  4. Copy the entire folder 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.

  5. The IAM role tied to the agent (AWS) or the managed identity (Azure) must have certain user permissions to access this storage location. Read Storing external files for details of these permissions.

  6. Set an agent parameter EXTENSION_LIBRARY_LOCATION, with the value being the absolute path of the cloud storage folder containing the package and its dependencies, for example AWS (S3): s3://my-additional-libraries and Azure Blob Storage: https://mystorageaccount.blob.core.windows.net/my-files. Read Optional agent parameters for details.

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

Got feedback or spotted something we can improve?

We'd love to hear from you. Join the conversation in the Documentation forum!