Skip to content

Instantly share code, notes, and snippets.

@Foadsf
Last active September 27, 2024 09:10
Show Gist options
  • Save Foadsf/c134ab9a8d79cdeda139807b759daf2a to your computer and use it in GitHub Desktop.
Save Foadsf/c134ab9a8d79cdeda139807b759daf2a to your computer and use it in GitHub Desktop.
A step-by-step guide to set up Quarto with Visual Studio Code and Python for literate programming on Windows.

Quarto, VS Code, and Python for Literate Programming on Windows

This guide will help you set up Quarto, Visual Studio Code, and Python for literate programming (also known as entangling) on Windows.

Prerequisites

  • Windows operating system
  • Python installed
  • Visual Studio Code installed

Steps

  1. Install Quarto

    Choose one of the following methods:

    • Using Chocolatey (if installed):

      choco install quarto -y
      
    • Using winget (if available):

      winget install Quarto
      
  2. Install required Python packages

    Open a command prompt and run:

    py -m pip install jupyter matplotlib plotly
    

    Note: Only Jupyter is required for Quarto, but matplotlib and plotly are needed for the official example.

  3. Install the Quarto VS Code Extension

    Install the extension from the Visual Studio Marketplace.

  4. Create a Quarto document

    Open VS Code in your desired folder and create a new file with the .qmd extension.

  5. Ensure correct Python environment

    Verify that VS Code is using the correct Python installation:

    • Check Python version in PowerShell or cmd:
      python --version
      where python
      
    • If VS Code is not using the correct Python, update settings.json:
      {
        "python.defaultInterpreterPath": "path\\to\\your\\python"
      }
    • This can be set at the user, workspace, or folder level.
  6. Render the document

    Use the keyboard shortcut: Ctrl + Shift + K

For more details, check out the official Quarto tutorial.

@Foadsf
Copy link
Author

Foadsf commented Sep 27, 2024

This is a follow up to:

  • This SO post
  • This Twitter conversation
  • This Reddit conversation

I have also shared this Gist here on Reddit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment