It will help if we could know the version of frappe that you are trying to install and the instructions being followed, including the command that produced the error message.
Yuo need to upgrade to pythone3.10
using the below commands.
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
Verify the updated Python packages list using this command.
apt list | grep python3.10
install Python 3.10 by using the below command :
sudo apt-get install python3.10
Add both old and new versions of Python to Update Alternatives.
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 2
sudo update-alternatives --config python3
You should get Python 3.10 as output.