Skip to main content

MaixPy Python3 library

Project description

MaixPy3 Logo

MaixPy3 GitHub forks GitHub stars GitHub watchers

English | 简体中文

MIT PyPI version Python issue

MaixPy3 is a Python3 toolkit based on cpython, which simplifies the development of applications on Linux AI edge devices through Python programming.



Display the camera image on the screen.

from maix import display, camera

After inputting the image to the model, the result of the forward algorithm is returned.

from PIL import Image
from maix import nn

m = nn.load({
    "param": "/root/models/resnet_awnn.param",
    "bin": "/root/models/resnet_awnn.bin"
  }, opt={
    "model_type":  "awnn",
    "inputs": {
        "input0": (224, 224, 3)
    "outputs": {
        "output0": (1, 1, 1000)
    "first_layer_conv_no_pad": False,
    "mean": [127.5, 127.5, 127.5],
    "norm": [0.00784313725490196, 0.00784313725490196, 0.00784313725490196],

img ="input.jpg")
out = m.forward(img, quantize=True)
out = nn.F.softmax(out)
print(out.max(), out.argmax())

Some examples of accessing hardware peripherals.

  • GPIO
import time
from maix import gpio
PH_BASE = 224 # "PH"
gpiochip1 = gpio.chip("gpiochip1")
led = gpiochip1.get_line((PH_BASE + 14)) # "PH14"
config = gpio.line_request()
config.request_type = gpio.line_request.DIRECTION_OUTPUT

while led:
  • PWM
import time
from maix import pwm

with pwm.PWM(6) as pwm6:
  pwm6.period = 1000000
  pwm6.duty_cycle = 10000
  pwm6.enable = True
  while True:
    for i in range(50, 1, -10):
      pwm6.duty_cycle = i * 10000
    for i in range(1, 50, +10):
      pwm6.duty_cycle = i * 10000
  • I2C
from maix import i2c
i2c = i2c.I2CDevice('/dev/i2c-2', 0x26)
i2c.write(0x1, b'\xAA')
print(, 1))
  • SPI
from maix import spi
spi = spi.SpiDev(), 0) # '/dev/spidev1.0'

spi.bits_per_word = 8
spi.max_speed_hz = 1
spi.mode = 0b11

import time

while True:
  to_send = [0x01, 0x02, 0x01]
  print(spi.xfer2(to_send, 800000)) # 800Khz
  • UART
from maix import serial

with serial.Serial("/dev/ttyS1",115200) as ser:
  ser.write(b"Hello Wrold !!!\n")
  tmp = ser.readline()
from maix import evdev
from select import select
dev = evdev.InputDevice('/dev/input/event9')

while True:
  select([dev], [], [])
  for event in
    print(event.code, event.value)

See the documentation for more information


Install rpyc_ikernel kernel in jupyter notebook & lab to get an IDE that can remotely call Python code, videos, and image streaming.

Click here to view the effect usage_display_hook.ipynb. Note that jupyter runs on your computer.


Platform Status Example config Memory usage
linux x86_64 working general general unlimited
maix_v83x working maix_v83x maix_v83x 11M+
maix_r329 working maix_r329 maix_r329 unknown
Windows build fail

The development progress is in no particular order.


Under linux x86_64, use python3 build to complete the general package construction.

For other platforms, take the version of maix_v83x as an example, match the Python3 + cross-compilation chain of the corresponding platform(toolchain_v83x_linux_x86), and run python3.8 build maix_v83x to complete the construction of the target platform package.

Welcome to provide configurations of different platforms to MaixPy3/envs/ to adapt to the MaixPy3 environment.

If you need .whl pre-compiled package, please change build to bdist_wheel.


Tested glibc >= 27 on Ubuntu20.04 & manjaro20.03.

Each catalog function of the project.

  • docs [store some general development documents]
  • envs [store compilation configurations for different platforms]
  • examples [store examples or applications on different platforms]
  • ext_modules [store project modules that need to be compiled]
  • maix [Provide maix entry Python module]
  • tests [Provide tox common test items]
  • [MaixPy3 project compilation entry]

If you want to submit the configuration of other platforms, please refer to the following:

_maix_modules = [

_maix_data_files = [
    ('/maix', get_srcs(ext_so, ['so' 'ko'])),

_maix_py_modules = [

If you want to submit some Python and C modules that need to be compiled, it is recommended to use the sub-repository to import, refer to the following:

If you want to submit some useful Python tools or sample code, refer to the following:


All this comes from the power of open source. Thanks to them, they are listed in no particular order.

The open source repositories that may be cited in the future are also grateful to them.

You are welcome to recommend the open source projects you need. If you find any missing projects, please let me know immediately.


Copyright (c) Sipeed Corporation. All rights reserved.

Licensed under the MIT license.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for maixpy3, version 0.3.4
Filename, size File type Python version Upload date Hashes
Filename, size maixpy3-0.3.4-cp38-cp38-linux_armv7l.whl (3.6 MB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size maixpy3-0.3.4-cp39-cp39-manylinux2014_aarch64.whl (20.5 MB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size maixpy3-0.3.4.tar.gz (13.3 MB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page