top of page
Writer's pictureH-Barrio

Installing and Running Mojo on Windows

Modular's Mojo language could be the solution to embedded artificial intelligence needs. The memory overhead and processor demands from pure Python are still complicated to integrate into embedded solutions. For any safety-critical application, using Python is very difficult to justify, thanks to its flexible variable and object handling. Python's strengths are its weaknesses for embedded and safety-critical applications, and Mojo could be the starting point to remove these weaknesses wherever needed.


Mojo claims a considerable improvement in computation speed while using a syntax very similar to that of Python while requiring the declaration and definition of constants and variables and very minor, in our opinion, changes to the Python syntax we are familiar with. For all the claimed benefits from Mojo, follow this link and see for yourself; Chapter 01:Usability explains this well.


To start running Mojo on our own systems, as opposed to the playground Modular has been offering; we will need to follow these steps if your system is Windows-based. Native Windows support seems to be coming in the future; we will need to use WSL, the Windows Subsystem for Linux, to allow us to "emulate" (not emulate, as we have an entire virtual machine) Linux. WSL is not installed by default in standard Windows installations, so go to the Microsoft Store (start, type "Microsoft store"), search for WSL, and install it by hitting "Get":



Search the store for Ubuntu 22.04.2 LTS and install it:


You may need to restart the system after each install operation to ensure everything is loaded correctly. With WSL and Ubuntu installed, you should be able to run a command prompt (search for CMD in Windows start) or Windows Powershell (same, search for Powershell) in administrator mode. You can run WSL from any drive by navigating to that drive and executing WSL:


The first time you run WSL, it may ask you for a username and password to use as root user. If you are not taken directly to the Linux command prompt, type the following Windows command that should perform the previous operations in a single command and restart the system:

wsl --install -d ubuntu

Install now the Modular CLI:

curl https://get.modular.com | \
  MODULAR_AUTH=mut_7c6a56f205d749e5ac4033ff1b21f2ba \
  sh -

And the Mojo SDK:

modular install mojo

Run these commands to set up your environment variables:

echo 'export MODULAR_HOME="$HOME/.modular"'>> ~/.bashrc
echo 'export PATH="$MODULAR_HOME/pkg/packages.modular.com_mojo/bin:$PATH"'>> ~/.bashrc
source ~/.bashrc

Everything is ready to write our first Mojo program. To make things simple, go to Windows Notepad and create a text file with this sample MOJO program:

def main():
	print("hello world")
	for x in range(9, 0, -3):
		print(x)

Store your file in a known location; we are using E:\MojoProjects\trial.mojo as the location and name of our file. In the Windows command window, navigate to the location of your program file and run:

mojo trail.mojo

You should see the following program result:


This first program could be a Python program; the difference is a minimal explicit "main" function declaration for Mojo to interpret and run. In upcoming posts, we will compare and adapt existing Python scripts to Mojo scripts while measuring the performance improvements we can receive.


Do not hesitate to contact us if you require quantitative model development, deployment, verification, or validation. We will gladly help you with your machine learning or artificial intelligence challenges when applied to asset management, automation, or intelligence gathering from satellite, drone, or fixed-point imagery.

2,955 views0 comments
bottom of page