Search code examples
pythonc++ccmakeopenwrt

Use Python 3 in OpenWRT Build System


Trying to create OpenWRT build system for Omega linux on chip device according to manual on my Ubuntu 20. Got error below while run make menuconfig

...
Checking 'python'... failed.
...
Build dependency: Please install Python 2.x

My system has Python 3 while manual asks to install Python 2.

How to solve this problem?


Solution

  • Since Python3 is not backward compatible you need to provide Python2 for installation. Follow this instructions to create an isolated Python2 environment in your system:

    1. Install Python2 (add repository if needed):
    sudo apt install python2
    
    1. Install pip (package manager):
    curl https://bootstrap.pypa.io/get-pip.py --output get-pip.py
    
    sudo python2 get-pip.py
    
    1. Install virtualenv:
    sudo apt install virtualenv
    
    1. Create virtual environment for Python2 in your favorite directory (change myenv to your favorite name):
    virtualenv --python=python2 myenv
    
    1. Activation:
    source myenv/bin/activate
    
    1. Deactivation:
    deactivate
    

    You can also install required python packages (if needed) by using pip in your activated environment.