Using CodeWhisperer with JupyterLab - CodeWhisperer

CodeWhisperer's features are becoming a part of Amazon Q Developer. Learn more

Using CodeWhisperer with JupyterLab

This page describes how to set up and activate Amazon CodeWhisperer for JupyterLab. Once activated, CodeWhisperer can make code recommendations automatically as you write your code.

Note

Python is the only programming language that CodeWhisperer supports in JupyterLab.

Installing JupyterLab itself

Install JupyterLab on your computer or if you already have JupyterLab installed, check it’s version by running the following command.

pip show jupyterlab

Note the version in the response, and follow the use the corresponding directions in one of the following sections.

Installation Using Pip for Jupyter Lab version >= 4.0

You can install and enable the CodeWhisperer extension for JupyterLab 4 with the following commands.

# JupyterLab 4 pip install amazon-codewhisperer-jupyterlab-ext sudo systemctl restart jupyter-server

After running the code above, refresh your browser. You should be able to use CodeWhisperer.

If you encounter a permissions issue, run:

aws sts get-caller-identity

This will return the name of the identity that requires permission to use CodeWhisperer. If you are using SageMaker, then it will be the SageMaker execution role.

Add the appropriate permissions to the role, and refresh your browser again.

Installation Using Pip for Jupyter Lab version >= 3.6 and < 4.0

You can install and enable the CodeWhisperer extension for JupyterLab 3 with the following commands.

# JupyterLab 3 pip install amazon-codewhisperer-jupyterlab-ext~=1.0 jupyter server extension enable amazon_codewhisperer_jupyterlab_ext sudo systemctl restart jupyter-server

After running the code above, refresh your browser. You should be able to use CodeWhisperer.

If you encounter a permissions issue, run:

aws sts get-caller-identity

This will return the name of the identity that requires permission to use CodeWhisperer. If you are using SageMaker, then it will be the SageMaker execution role.

Add the appropriate permissions to the role, and refresh your browser again.

Authenticating with AWS Builder ID

In the following procedure, you will set up Builder ID, which you will use to authenticate when you enable CodeWhisperer.

  1. Refresh the browser tab on which you are using JupyterLab.

  2. From the CodeWhisperer panel at the bottom of the window, choose Start CodeWhisperer.

  3. From the pop-up window, choose Copy Code and Proceed.

  4. On the Create AWS Builder ID page, if you don't have a Builder ID, enter a personal email address and choose Next.

    If you already have a Builder ID, skip to the step about the Authorize request page.

  5. On the next Create your AWS Builder ID page, enter a name and choose Next.

  6. After you receive your email verification code, enter it in the blank field and choose Verify.

  7. On the next screen, choose and confirm a password, then choose Create AWS Builder ID

  8. On the next page choose Allow to allow CodeWhisperer to access your data.

Now you should be logged into CodeWhisperer in JupyterLab with Builder ID.

To begin coding, see User actions.

An example of CodeWhisperer in use with JupyterLab.