mojo-python-interop

Convert Python objects and Mojo types across language boundaries.

123|11|Updated Feb 25, 2026
One-click install
npx skills add https://github.com/modular/skills --skill mojo-python-interop
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mojo-python-interop
Source: https://github.com/modular/skills/tree/main/mojo-python-interop
Command: npx skills add https://github.com/modular/skills --skill mojo-python-interop

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the challenges of integrating Mojo and Python code, ensuring correct syntax and conventions are used for interoperability, especially as Mojo's Python integration capabilities are rapidly evolving.

Core Features & Use Cases

  • Python from Mojo: Guides on importing Python modules, converting Python objects to Mojo types, and building Python collections from Mojo.
  • Mojo from Python: Provides patterns for exporting Mojo functions and types as Python extension modules.
  • Use Case: You need to use a Python library like NumPy within your Mojo project or expose a Mojo-defined data structure to a Python script.

Quick Start

Use the mojo-python-interop skill to import the 'numpy' Python module and create a numpy array from a Mojo list.

Frequently Asked Questions about mojo-python-interop

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I call Python libraries from Mojo?

To call Python libraries from Mojo, you import Python modules directly into your Mojo code and manipulate dynamic Python objects. This interoperability allows you to leverage existing Python packages like NumPy within your Mojo projects.

How do I expose Mojo code as a Python extension module?

You can expose Mojo code as a Python extension module by exporting Mojo functions and types. This allows Python scripts to import and execute your Mojo-defined data structures and functions directly.

Can I convert Python objects to Mojo types?

Yes, you can convert Python objects to Mojo types and build Python collections from Mojo. The integration manages type conversions between the two ecosystems to ensure data compatibility.

Does Mojo handle Python exceptions across language boundaries?

Yes, Mojo handles Python exceptions across language boundaries. The interoperability framework supports dynamic Python object manipulation while managing exception propagation between the Mojo and Python ecosystems.

What is the best way to use NumPy arrays in a Mojo project?

The best way to use NumPy arrays in a Mojo project is to import the NumPy Python module and create arrays from Mojo lists. This approach facilitates seamless type conversion and dynamic object manipulation.