Skip to content

AWS Glue Visual ETL - Install/ import packages

0

Im trying to install and use a Python package that is not native in AWS Glue Visual ETL - Custom Transform node.

!pip install textdistance -> !pip is invalid syntax in the Custom Transform code

Wondering how can I install and use this module in this transformation block using Visual ETL instead of creating a notebook? If it can't be done using this way, what are the alternatives (preferably sticking with Visual ETL)?

Enter image description here

asked 2 years ago759 views

2 Answers
1
Accepted Answer

Installing and using custom Python packages in AWS Glue Visual ETL jobs can be achieved, but it requires a slightly different approach than using !pip install directly in the Custom Transform node.

To use a custom Python package like 'textdistance' in your AWS Glue Visual ETL job, you have a few options:

  1. Use the --additional-python-modules parameter: When creating or editing your Glue job, you can specify additional Python modules to be installed. In the job properties or advanced properties section, add the parameter --additional-python-modules and set its value to the package you want to install, for example: textdistance==4.2.1 (specify the version you need).

  2. Include the package in a ZIP file: If the package is not available through pip or you need a specific version, you can create a ZIP file containing the package and its dependencies. Upload this ZIP file to an S3 bucket, and then specify the S3 path in your job's Python library path setting.

  3. Use a custom runtime environment: Create a custom runtime environment that includes the packages you need, and use this environment for your Glue job.

After setting up one of these methods, you should be able to import and use the package in your Custom Transform node without needing to use !pip install.

For example, in your Custom Transform code, you could then simply use:

import textdistance

# Your transformation logic using textdistance

If you prefer to stick with Visual ETL and avoid creating a separate notebook, the first two options are your best bet. They allow you to add the necessary packages while still using the visual interface for job creation and management.

Remember that when using custom packages, you need to ensure that they are compatible with the Python version and environment used by your AWS Glue job. Always test your job thoroughly after adding custom packages to ensure everything works as expected.

Sources
Using Python libraries with AWS Glue - AWS Glue
Building visual ETL jobs with AWS Glue Studio - AWS Glue
AWS Glue concepts - AWS Glue

answered 2 years ago

EXPERT

reviewed 2 years ago

0

I have utilized Step 1 for Visual ETL and i'm able to import and utilize textdistance package successfully.

Enter image description here

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.