This article discusses downloading and building PyScript from the source for Ubuntu 20.04 running within Windows WSL. For Linux, skip over the first section covering WSL setup.

This article is written for the Python developer with limited experience building JavaScript/Node.js applications.

Why would you want to do this:

  • There are some interesting examples—building from source and running the dev server with the latest PyScript code.
  • You want to follow new Pyscript features. By comparing source code changes, you can track what is changing. This includes new features and bugs.
  • You simply want the latest version and are willing to work through compatibility issues and bugs.
  • You plan to study the source code and possibly contribute to the project.

Setting up WSL

There are a number of Linux distributions available for WSL. I will use Ubuntu 20.04 LTS.

Open an elevated Command Prompt. Install Ubuntu 20.04:

Command output:

Reboot your system.

If you are running Windows inside a Hyper-V VM, you might receive this error:

This means the installation failed and will need to be repeated. The key is to enable Nested Virtualization.

Open an elevated PowerShell Command Prompt. Replace <VMName> with the name of the virtual machine.

Start the virtual machine.

Repeat the Ubuntu installation if the first attempt failed:

You should have command output similar to:

You are now running in the WSL Linux shell. The default shell for Ubuntu is bash. To double-check:

Command output:

Update and upgrade the Ubuntu system

To exit the WSL Linux shell:

This returns you to the Windows command prompt.

To return to WSL

If you are running more than one Linux distribution in WSL

Check the status of WSL

Command output:

Downloading PyScript

The simplest method is to use the git CLI. Periodically, the PyScript releases tagged versions, which you can download as .zip or .tar.gz archives.

Change directories to a location where you want to download the PyScript project. Then run the following command to clone the PyScript repository:

Command output:

Install PyScript dependencies

The version of WSL Ubuntu version of Node.js is out of date. Remove it first:

Install nvm to manage node versions:

Install the latest LTS version of Node.js:

Command output

Change into the PyScript source directory

Install the PyScript dependencies:

There are two build options: dev and build.

After a few minutes, the build completes and the development web server starts.

Open a browser on the host system and go to http://localhost:8080.


Building PyScript and running the development server is very easy. Once your environment is set up, you can begin to directly work with the source code.

Photography Credit

I write free articles about technology. Recently, I learned about which provides free images. The image in this article is courtesy of cmonphotography at Pexels.