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.
- pixi
- uv
-
If you don't have it, install
pixi:curl -fsSL https://pixi.sh/install.sh | sh -
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-worldThis creates a project directory named
hello-world, adds the channel for Modular conda packages, and enters the directory.
-
Install Mojo (stable):
pixi add "mojo==0.26.2"
-
Enter the virtual environment so you can access the
mojoCLI:pixi shell
-
If you don't have it, install
uv:curl -LsSf https://astral.sh/uv/install.sh | shThen restart your terminal to make uv accessible.
-
Create a project:
uv init hello-world && cd hello-world -
Create and start a virtual environment:
uv venv && source .venv/bin/activate
-
Install Mojo (stable):
uv pip install mojo \ --extra-index-url https://modular.gateway.scarf.sh/simple/
Verify your installation by printing the Mojo version:
mojo --versionAdd 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:
- The Visual Studio Code Marketplace, for VS Code users
- The Open VSX Registry, for users of Cursor and other editors that support VS Code extensions
Or, open the Extensions view in your IDE and search for "Mojo"—make sure you install the extension from Modular.
Print "Hello world"
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:
-
Create a file named
hello.mojowith this code:hello.mojodef main() raises: print("Hello, World!") -
Run it with the
mojoCLI:mojo hello.mojoHello, 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/skillsTry 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.
-
Clone the repository:
git clone https://github.com/modular/modular.git -
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 -
Use
pixito 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 lifev1This 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
- uv
pixi update mojouv sync --upgrade-package mojoUninstall
Mojo is installed as a Python or Conda package, so the normal package removal process applies.
- pixi
- uv
This removes the package from your local project:
pixi remove mojoThis deactivates your virtual environment:
exitThis removes the package from your local environment:
uv pip uninstall mojo && uv syncThis deactivates your virtual environment:
deactivateSystem requirements
Relocated to the system requirements page.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!