skip to Main Content

I am not able to run

from sagemaker.predictor import csv_serializer

Following is the import error I am getting.

ImportError: cannot import name ‘csv_serializer’ from ‘sagemaker.predictor’ (/home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages/sagemaker/predictor.py)

I tried running following command on notebook instance in sagemaker.

!{sys.executable} -m pip install sagemaker==1.72.0 -U

2

Answers


  1. Did you try restarting the kernel after running the pip install command?

    Note that csv_serializer was deprecated in v2 of the SDK, so updating your usage is the correct long-term solution. See v2 documentation for the new usage.

    Login or Signup to reply.
  2. Update the sagemaker to latest version pip install --upgrade sagemaker. And then try the following steps to get CSV Serializer.

    Import the following

    from sagemaker.serializers import CSVSerializer
    

    Usage

    xgb_predictor.serializer = CSVSerializer()
    

    Reference: https://docs.aws.amazon.com/sagemaker/latest/dg/ex1-model-deployment.html

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search