Search code examples
openwrt

How to include Python pip3 modules in OpenWRT image


I'm going to include pip3 modules in OpenWRT image, so it won't require other dependencies after installed OpenWRT image.

For example, I'm going to include argparse module in OpenWRT image. This module may be installed by the following command in initial OpenWRT image:

opkg install python3
pip3 install argparse

How can I include them in initial OpenWRT firmware?

Thanks!


Solution

  • First, run make menuconfig, and then select Languages -> Python, and then select python3,python3-pip, then save and then exit.

    Next, run ./scripts/env new py3-argparse to create a build environment for your changes.

    Finally, download the argparse library and place it in files/lib/python3.6/site-packages.

    References:

    OpenWrt - Build Environments

    Python3 - argparse (source)