This is caused by not installing python3.x-dev. Solution:
sudo apt-get install python3.x-dev
If an error is reported and the package cannot be located, then you can do this (pay attention to whether the python version in the installation information corresponds to your own)
sudo apt-get install python3-dev