Using interactive sessions with Microsoft Visual Studio Code - Amazon Glue
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China.

Using interactive sessions with Microsoft Visual Studio Code


  • Install Amazon Glue interactive sessions and verify it works with Jupyter Notebook.

  • Download and install Visual Studio Code with Jupyter. For details, see Jupyter Notebook in VS Code.

  1. Disable Jupyter AutoStart in VSCode.

    In Visual Studio Code Jupyter kernels will auto-start which will prevent your magics from taking effect as the session will already be started. To disable autostart Go to Code > Preferences > Settings > Extensions > Jupyter > Jupyter: Disable Jupyter Auto Start. Check the box labeled "When true, disables Jupyter from being automatically started for you. You must instead run a cell to start Jupyter."

              The screenshot shows the checkbox enabled in for the Jupyter Extension in VS Code.
  2. Go to File > New File > Save to save this file with name of your choice as an .ipynb extension or select jupyter under select a language and save the file.

              The screenshot shows the file being saved with a new name.
  3. Double-click on the file. The Jupyter shell will display and a notebook will be opened.

              The screenshot shows the open notebook.
  4. When you first create a file, by default it has no kernel selected. Click on Select Kernel and a list of available kernels is displayed. Choose Glue PySpark.

              The screenshot shows the Select Kernel button highlighted.

    Choose the Glue PySpark or Glue Spark kernel (for Python and Scala respectively).

              The screenshot shows the selection for Amazon Glue PySpark.

    If you don't see Amazon Glue PySpark and Amazon Glue Spark kernels in the drop-down list, please ensure you have installed the Amazon Glue kernel in the step above, or that your python.pythonPath in setting Visual Studio Code is correct. To validate the python.pythonPath see the steps below.

    1. In MS VS Code, navigate to Manage > Settings. Click on the open settings icon.

                  The screenshot shows the settings tab, Text Editor page.
    2. python.pythonPath should be pointing to your Python environment python >location path<. If you opened Visual Studio Code from a virtual environment with code ., it will point to the pythonPath of that virtual environment.

    3. If you don't see python.pythonPath please add it and restart Visual Studio Code. See examples below.

      { "python.pythonPath":"Python path of Python Virual environment" }
      { "python.pythonPath":"/Users/username/Documents/interactive_sessions_demo/lib/python3.8" }
                  The screenshot shows the settings tab, Text Editor page.
  5. Create an Amazon Glue Interactive Session. Proceed to create a session in the same manner as you did in Juptyer Notebook. Specify any magics at the top of your first cell and run a statement of code.