Pyret Updates 2025

We’ve released a few improvements and new features in Pyret that we are excited to share!

  • A Visual Studio Code extension for running Pyret
  • Improvements to offline Pyret via pyret-npm and the VScode extension
  • New ways to import modules
  • New ways to work with files, URLs, and images
  • A new library for embedding Pyret in web pages
  • Documentation and naming convention clean up
  • Various bug fixes across libraries

There should be no backwards incompatibilities in this release for existing code.

VScode Extension

Pyret now has a VScode extension:

Pyret Interactive Editor for VSCode

There are a few exciting things about this:

  • If you're familiar with VScode for managing code, you can work with Pyret files within VScode with a full-featured visual editor with images, animations, interactions area, and so on, just like on code.pyret.org.
  • The extension is a fully capable web extension, meaning it can run on github.dev. This means it provides another path to editing and running Pyret code (for free) without leaving the browser, with just a Github account.

Improvements to Offline Pyret

The command-line version of Pyret, which most folks use through the npm package, has seen a few improvements:

  • The image library is now fully functional from the command line. It uses the node-canvas npm package to do this. From the command line—and from the VScode mode!—you can use image-file to read images from a local path, and save-file to save (and later view) images.
  • We've added and documented a few new libraries including csv, filesystem, and fetch for getting more work done from the command line.

New Ways to Import Code and Data

We've added the ability to import modules from URLs with url(...) and url-file(...) imports. This allows for development of student-facing starter code and libraries for code.pyret.org without relying on Google Drive. We've also added functions to create tables from CSV data loaded from files or from URLs; previously this kind of data import really only worked well from Google Sheets. Now arbitrary CSV files can be loaded into tables from the filesystem or the web (or arbitrary text data with fetch).

A New Embedding Library

You can now embed the code.pyret.org editor directly into other web pages with pyret-embed. Indeed, this is what is used to create the VScode extension! The embedding library is suitable for showing interactive examples in online tutorials, creating interactive lessons, presenting student code to TAs in a web-based autograder, and more. We're curious what you build with it!

Documentation Updates

We've significantly updated and improved documentation of many core libraries. In addition, we've used the embedding library to make most of the examples in the docs runnable. For example, click the (Try it!) button in the numbers documentation.