Last modified: Jun 16, 2026
Install Mojo AI Programming Language
Mojo is a new programming language designed for AI and machine learning. It combines Python-like syntax with high performance. This guide shows you how to install Mojo on your system.
We cover the official installation method using Modular CLI. You need a Linux or macOS system. Windows users can use Windows Subsystem for Linux.
Let's start with the prerequisites and step-by-step process.
Prerequisites for Mojo Installation
Before you install Mojo, ensure your system meets these requirements:
- A 64-bit Linux distribution (Ubuntu 20.04+, Fedora 35+) or macOS 12+
- At least 2 GB of free disk space
- Internet connection to download packages
- Basic knowledge of terminal commands
You also need Python 3.8 or later installed. Mojo uses Python for some integrations. Check your Python version with this command:
python3 --version
If Python is missing, install it using your package manager. For Ubuntu, run sudo apt install python3 python3-pip.
Step 1: Install Modular CLI
Mojo is distributed through the Modular CLI. This command-line tool manages Mojo installations. Open your terminal and run this command:
curl -s https://get.modular.com | sh
This script downloads and installs the Modular CLI. It adds the modular command to your system. You might need to restart your terminal after this step.
If you prefer manual installation, visit the official Modular website. Download the appropriate binary for your OS.
Step 2: Authenticate with Modular
Mojo is currently in early access. You need to authenticate with a free Modular account. Run this command:
modular auth
The CLI opens a browser window. Log in or create a new account. After authentication, you see a success message in the terminal.
This step is mandatory. Without authentication, you cannot download Mojo packages.
Step 3: Install Mojo Package
Now install the Mojo package using the modular install command:
modular install mojo
The installer downloads the latest Mojo version. It places all files in the ~/.modular directory. This process takes a few minutes depending on your internet speed.
After installation, verify the Mojo binary path. Use this command:
which mojo
If you see a path like /home/user/.modular/bin/mojo, the installation succeeded.
Step 4: Add Mojo to PATH
To use Mojo from any directory, add it to your PATH. Run this command:
export PATH="$HOME/.modular/bin:$PATH"
For permanent changes, add the line to your shell configuration file. For Bash, edit ~/.bashrc. For Zsh, edit ~/.zshrc.
Add this line at the end of the file:
export PATH="$HOME/.modular/bin:$PATH"
Then reload the file with source ~/.bashrc or source ~/.zshrc.
Step 5: Verify Mojo Installation
Check if Mojo works correctly. Run the version command:
mojo --version
You should see output like mojo 24.4.0. The version number may differ based on the latest release.
Now write your first Mojo program. Create a file named hello.mojo with this code:
# This is a simple Mojo program
fn main() -> None:
print("Hello, Mojo!")
Run it with the Mojo interpreter:
mojo hello.mojo
The output should be:
Hello, Mojo!
Common Installation Issues
You might face some problems during installation. Here are solutions for common errors:
Error: "modular: command not found"
This means the Modular CLI installation failed. Re-run the curl command. Ensure you have curl installed with sudo apt install curl.
Error: "Authentication failed"
Your login credentials might be incorrect. Run modular auth again. Make sure you use the same email as your Modular account.
Error: "Permission denied"
You lack write permissions to the installation directory. Run the install command with sudo or change directory ownership.
Using Mojo with Python
Mojo integrates seamlessly with Python. You can import Python modules directly. This makes it easy to use existing AI libraries.
Here is an example using Python's math module in Mojo:
# Import Python's math module
from python import math
fn main() -> None:
# Calculate square root using Python
var result = math.sqrt(25.0)
print("Square root of 25 is:", result)
Run this code with mojo math_example.mojo. The output shows:
Square root of 25 is: 5.0
This interoperability is a key feature of Mojo. It allows you to leverage Python's vast ecosystem while enjoying Mojo's performance.
Uninstalling Mojo
If you need to remove Mojo, use the Modular CLI:
modular uninstall mojo
This removes all Mojo files from your system. You can also delete the ~/.modular directory manually.
To uninstall the Modular CLI itself, run:
curl -s https://get.modular.com | sh -s -- --uninstall
Conclusion
Installing Mojo AI programming language is straightforward with the Modular CLI. You need to authenticate, download the package, and set your PATH.
After installation, you can write high-performance AI code with Python-like syntax. Mojo supports GPU acceleration and advanced memory management.
Start experimenting with small examples. Explore the official documentation for more advanced features. Mojo is a powerful tool for AI development.