Custom package installation from S3 in sagemaker

1.3k views Asked by At

I have a whl file for a custom package (not published open source) in a S3 bucket.

I now want to import/install it in my sagemaker instance. https://medium.com/@shadidc/installing-custom-python-package-to-sagemaker-notebook-b7b897f4f655 This link is what I tried to follow, but it did not work for me.

Has anyone tried this before?

1

There are 1 answers

0
Vikash Kumar On

Using AWS Sagemaker Jupyter cell

Option 1 :

Quick and dirty, upload the whl file in same workspace as of notebook and just install.

%pip install custom_package_name.whl

Now, you would need to restart the kernel and then import. You should be able to work through.

Option 2:

Another simple approach is to get the whl file from S3 folder and install.

s3 = boto3.client("s3")
s3_bucket = "your core s3 bucket location"
file_location = "your file location and file name with extension"

Below I'm using same file location for both source and target

s3_client.download_file(s3_bucket, file_location, file_location)

%pip install ./your_target_folder_name/custom_package.whl

Now, you would need to restart the kernel and then import. You should be able to work through.