Can't import sagemaker in CI_W1 Assignment

I am getting error TypeError: Descriptors cannot not be created directly.
If this call came from a file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:

  1. Downgrade the protobuf package to 3.20.x or lower.
  2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
    when trying to import sagemaker.
    Sagemaker is installed using !pip install --disable-pip-version-check -q sagemaker==2.35.0

Hi, I ran into the same issue and resolved it by:

  1. Restart Kernel
  2. Add the following code as the first import ( before any other imports ):
    !pip install protobuf==3.20.1

You can then go through the notebook without any issues.