'gem5 build fails with " Embedded python library 3.6 or newer required, found 2.7.17."

I cannot build gem5, when I build gem5,the terminal shows " Embedded python library 3.6 or newer required, found 2.7.17.".However,when I check my python version, I find my python version is 3.6.

python --version

Python 3.6.7



Solution 1:[1]

The gem5 build environment does not use your user environment. This means your custom values for PATH and other environment variables won't be set. My intuition is your Python 3 installation is pointed to by one of your custom values. In the absence of these, gem5 uses the Python system installation, which is Python 2 in your case.

You can instruct the gem5 build process to use a particular Python installation through the PYTHON_CONFIG build variable. To use your Python 3 installation:

scons PYTHON_CONFIG=python3-config ...

Solution 2:[2]

Try the below commands. It worked for me.

sudo apt-get update

sudo apt-get install python-dev scons m4 build-essential g++ swig

sudo apt install python3-pip

pip3 install scons

scons build/X86/gem5.opt -j8

Solution 3:[3]

On Ubuntu 20.04, or related Linux distributions, you may install all these dependencies using the command below:

sudo apt install build-essential git m4 scons zlib1g zlib1g-dev \
    libprotobuf-dev protobuf-compiler libprotoc-dev libgoogle-perftools-dev \
    python3-dev python-is-python3 libboost-all-dev pkg-config

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Adrián Herrera Arcila
Solution 2 Arjun Sunil Kumar
Solution 3 Navy