Skip to main content

Install Mojo

You can install Mojo as a Python or Conda package. This page shows you how to install using pixi and uv, but you can use other tools.

For a beginner's guide to Mojo, instead see the get started tutorial, which includes installation steps.

Install

To get the latest version, we recommend installing our nightly build. If you want a better tested but older version, install the stable build. Both options are shown below.

  1. If you don't have it, install pixi:

    curl -fsSL https://pixi.sh/install.sh | sh
  2. Navigate to the directory where you want to create a project and run this:

    pixi init hello-world \
      -c https://conda.modular.com/max-nightly/ -c conda-forge \
      && cd hello-world

    This creates a project directory named hello-world, adds the channel for Modular conda packages, and enters the directory.

  1. Install Mojo (stableTo get the nightly build, change the version in the website header.):

    pixi add "mojo==0.26.2"
  1. Enter the virtual environment so you can access the mojo CLI:

    pixi shell

Verify your installation by printing the Mojo version:

mojo --version

Add the VS Code extension

If you're using Visual Studio Code or another IDE derived from it (such as Cursor), we recommend installing the Mojo extension, which provides features like syntax highlighting, code completion, and debugging support. You can install it from either:

Or, open the Extensions view in your IDE and search for "Mojo"—make sure you install the extension from Modular.

If you followed the installation steps above, your terminal should be in an environment with mojo installed. To run some code, you just need a .mojo file with a main() function:

  1. Create a file named hello.mojo with this code:

    hello.mojo
    def main() raises:
        print("Hello, World!")
  2. Run it with the mojo CLI:

    mojo hello.mojo
    Hello, World!

Try Mojo agent skills

Use Mojo agent skills with your AI tools to generate more accurate Mojo code while learning Mojo:

npx skills add modular/skills

Try some examples

The examples/mojo/ directory of our public GitHub repository contains several examples of Mojo code that you can use to learn more about the language and its standard library. Here's how to download and use them.

  1. Clone the repository:

    git clone https://github.com/modular/modular.git
  2. Navigate to one of the Mojo example subdirectories, such as the subdirectory containing the reference solution for the Get started with Mojo tutorial project, which is an implementation of Conway's Game of Life cellular automation:

    cd modular/mojo/examples/life
  3. Use pixi to download and install the dependencies for the project and to build and run the examples. For example, to run the reference solution for the Game of Life tutorial project, use the following command:

    pixi run lifev1

    This displays a window that shows an initial random state for the grid and then automatically updates it with subsequent generations. Quit the program by pressing the Q or Esc key or by closing the window.

Update

The following commands should update your local mojo package if a new version is available that's compatible with the version you specified when you installed it or added it as a package dependency. For more information about updating packages, see the docs for your package manager.

pixi update mojo

Uninstall

Mojo is installed as a Python or Conda package, so the normal package removal process applies.

This removes the package from your local project:

pixi remove mojo

This deactivates your virtual environment:

exit

System requirements

Relocated to the system requirements page.

Was this page helpful?