In February 2022 I used these instructions to repair a hopelessly broken Python on an Ubuntu 16.04 machine that was prevent a release upgrade. Python was broken because apparently I had made the mistake of using
sudo pip installat some point, which one is strongly advised never to use.
pip install when-changed
Launch Python and in the REPL type help('modules'). This will list all modules whether built-in or modules stored in a custom PYTHONPATH. By using help('somemodule') you can obtain more information including the path to the *.py file for each module. From the file information where you can easily see if the module is built-in or rather present in some custom PYTHONPATH.
sudo apt-get install idle3
python -m site