How to add additional Python Libraries in a AWS Glue Development Endpoint

AWS Glue @

There are multiple scenario that you may need to use different set of python libraries in your python code or ETL scripts.

a. You can either set up a separate development endpoint for each set.

b. You can overwrite the library .zip file(s) that your development endpoint loads every time you switch scripts.

In the console you can  specify one or more library .zip files for a development endpoint when you create it. You can zip all the libraries and keep in a S3 path ( s3://freshers-in-bucket/prefix/ . If you may need to point to multiple zip files then you can mention all separated by comma (s3://freshers-in-bucket-A/prefix/,s3://freshers-in-bucket-B/prefix/ . If you are going to update the library then you can use the console to re-import them into your development endpoint.
You can specify library files using the AWS Glue APIs as well as bellow.

dep = glue.create_dev_endpoint(
PublicKey="ssh-rsa ASSDFEeerwTFJKTDSQWEQWFDGHGHGy...",

For Zeppelin Notebook

Call the following PySpark function before importing a package or packages from your .zip file


CreateJob : If you are doing a create job then you need to use –extra-py-files default parameter

job = glue.create_job(Name='freshersSampleJob',
Command={'Name': 'freshers_in',
'ScriptLocation': 's3://freshers_bucket/scripts/'},
DefaultArguments={'--extra-py-files': 's3://freshers-in-bucket-A/prefix/,s3://freshers-in-bucket-B/prefix/'})

For Jobrun , you can always override the default library setting with a different one

runId = glue.start_job_run(JobName='freshers_in_sampleJob',
Arguments={'--extra-py-files': 's3://freshers-in-bucket-A/prefix/'})
Author: user

Leave a Reply