Aspose python modules on AWS Lambda

Hello,
In my company We are considering contracting the Aspose API for file processing. Aspose-cells, Aspose-words, Aspose-slides, etc. We would like to run them in our Python AWS lambdas, but we’re not sure if we might encounter any problems since this API offers modules that run over .NET and Java. I have tried, and some work, but I’m not able to get others running (especially those that run on Java).

For example I have encountered this error:
[ERROR] Runtime.ImportModuleError: Unable to import module ‘lambda_function’: One or more errors occurred while loading the module ‘aspose.words’ (-1009)

When trying to use aspose-words and aspose-cells-python in the same lambda.
But if I use only aspose words there is no error.

Thank you for your support,
Diego Martín

@diegomartinmontoro

To run Aspose APIs, such as Aspose.Words and Aspose.Cells, in AWS Lambda using Python, you may encounter some challenges, especially since these libraries are built on .NET and Java. Here are some considerations and steps to help you troubleshoot the issues you’re facing:

  1. Compatibility: Ensure that you are using the correct version of the Aspose libraries that are compatible with Python. Aspose provides a Python library that is a wrapper around the .NET version, so make sure you are using aspose-words and aspose-cells specifically designed for Python via .NET.

  2. Lambda Layer: If you are using multiple Aspose libraries in the same Lambda function, consider creating a Lambda Layer that includes all the necessary dependencies. This can help avoid conflicts between different libraries.

  3. Error Handling: The error message you encountered (Runtime.ImportModuleError) suggests that there might be an issue with how the modules are being imported or with the environment setup. Make sure that:

    • All required libraries are included in your deployment package.
    • The Lambda function has the necessary permissions to access these libraries.
  4. Testing Individually: Since you mentioned that aspose-words works fine on its own, try isolating the issue by testing aspose-cells separately. This can help identify if the problem lies with a specific library or with the combination of both.

  5. Documentation and Support: Refer to the official Aspose documentation for Python via .NET for guidance on installation and usage. You can also check the Aspose support forum for similar issues and solutions provided by the community.

If you continue to face issues, consider reaching out to Aspose support for more tailored assistance regarding your specific setup and error messages.

For more information, you can refer to the official documentation: Aspose.Words for Python via .NET.

If you have any further questions or need additional help, feel free to ask!

@diegomartinmontoro,

  1. Could you please try ensuring that both libraries (Aspose.Words for Python and Aspose.Cells for Python) are compatible with the same .NET runtime version and package them in a way that avoids conflicts. Package aspose-words and aspose-cells-python in separate AWS Lambda layers to avoid conflicts. This can help isolate any conflicting dependencies between the two libraries.

  2. AWS Lambda limits the size of the deployment package and layers. So, the combined size of aspose-words, aspose-cells-python, and the .NET runtime might exceed this limit. Check the size of your Lambda package, including all dependencies (both .NET and Python libraries), and see if it’s within the limits.