Skip to content

Failed to import libraries

0

Hello,

Can you please help me on importing these libraries? gs_parse_json gs_flatten gs_explode

asked 2 years ago384 views

3 Answers
0

I apologize, but I don't have any information about the specific libraries you mentioned (gs_parse_json, gs_flatten, and gs_explode). These don't appear to be standard AWS libraries or commonly used Python libraries in AWS environments.

However, I can provide some general advice for importing libraries in AWS environments:

  1. Ensure the libraries are installed in your environment. If you're using a Lambda function, you may need to include these libraries in your deployment package or use Lambda Layers.

  2. Check that you're using the correct import syntax. For custom libraries, you might need to use the full path or ensure the library is in the Python path.

  3. If these are custom libraries you've created, make sure they're properly packaged and accessible in your AWS environment.

  4. For AWS services like Redshift that support custom Python libraries, you need to follow specific procedures to import custom modules. This involves creating a proper folder structure, compressing the package into a .zip file, uploading it to an S3 bucket, and then using the CREATE LIBRARY command to install it in your cluster.

  5. Verify that you have the necessary permissions to import and use these libraries in your AWS environment.

If you're still having issues, you may need to provide more context about your specific AWS service and environment, as well as the exact error messages you're encountering when trying to import these libraries.
Sources
Example: Importing custom Python library modules - Amazon Redshift

answered 2 years ago

AWS
SUPPORT ENGINEER

reviewed 2 years ago

0

Hello,

These python modules are Glue service modules which might not be present in public python repository.

so what you can try to do is download these Glue python modules from AWS public S3 bucket "s3://aws-glue-studio-transforms-737106620487-prod-ap-southeast-1/"

like => aws s3 cp s3://aws-glue-studio-transforms-737106620487-prod-ap-southeast-1/gs_parse_json.py s3://REPLACE-WITH-YOUR-S3-BUCKET/PATH

and then use them in your glue notebook/job. if in a glue notebook can use like below

%extra_py_files s3://REPLACE-WITH-YOUR-S3-BUCKET/PATH/gs_parse_json.py

and then import the module in the job/notebook.

Ref: https://docs.aws.amazon.com/glue/latest/dg/getting-started-min-privs-job.html

AWS
SUPPORT ENGINEER

answered 2 years ago

0

For gs_parse_json : When we use "Parse JSON Column" transform in visual etl glue job the following Python library path gets added in Advanced properties of the job "s3://aws-glue-studio-transforms-510798373988-prod-us-east-1/gs_common.py,s3://aws-glue-studio-transforms-510798373988-prod-us-east-1/gs_parse_json.py"

These are the internal buckets in which the packages exists. In case if you use create a spark ETL job or Glue notebook, to use this transform you have to add the above python library path explicitly; you can refer below steps for the same:

To add in glue job without visual: Go to job details > Under Libraries > Python library path > add the above s3 paths: [Python library path is same as adding --extra-py-files in job parameters.] [+]https://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-glue-arguments.html

To add in glue notebook: %extra_py_files <Comma separated list of additional Python files from Amazon S3>

Eg. %extra_py_files s3://aws-glue-studio-transforms-510798373988-prod-us-east-1/gs_common.py,s3://aws-glue-studio-transforms-510798373988-prod-us-east-1/gs_parse_json.py [+]https://docs.aws.amazon.com/glue/latest/dg/interactive-sessions-magics.html

AWS
EXPERT

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.