Going to choose another download server for software sources? You may found that Debian 11 ‘bullseye’ refused to open the dialog that contains the worldwide mirrors.
Debian, Ubuntu, and other Linux have many download servers worldwide. User can choose a nearest one, so installing apps from system repositories, either from Software Center or by command line tool (e.g., apt, dnf, pacman) will be super fast.
In Debian bullseye, when you trying to select ‘Other …‘ in Software & Updates or Software Sources utility, nothing happens. By starting it from terminal (run
sudo software-properties-kde depends on DE), you’ll see the error when choose ‘Download from Other’:
Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/softwareproperties/gtk/SoftwarePropertiesGtk.py”, line 553, in on_combobox_server_changed
dialog = DialogMirror(self.window_main,
File “/usr/lib/python3/dist-packages/softwareproperties/gtk/DialogMirror.py”, line 83, in __init__
self.country_info = CountryInformation()
File “/usr/lib/python3/dist-packages/softwareproperties/CountryInformation.py”, line 34, in __init__
it = et.getiterator(‘iso_3166_entry’)
AttributeError: ‘ElementTree’ object has no attribute ‘getiterator’
The error has something to do with the Python programming language. ‘bullseye’ has switched to Python 3.9.x. According to the release note, the getiterator() method has been removed and replaced via x.iter() or list(x.iter()).
getiterator()of classes ElementTree and Element in the ElementTree module have been removed. They were deprecated in Python 3.2. Use
x.getiterator(). (Contributed by Serhiy Storchaka in bpo-36543.)
Until Debian fixed the issue, the solution is simply to replace getiterator() with iter() in the error line.
Fix ‘ElementTree’ object has no attribute ‘getiterator’
According to the error output (see the previous picture), the file you need to edit is “/usr/lib/python3/dist-packages/softwareproperties/CountryInformation.py”.
1. Firstly search for and open terminal from start menu.
2. Next edit the python script via command:
sudo gedit /usr/lib/python3/dist-packages/softwareproperties/CountryInformation.py
NOTE: replace gedit for non-Gnome desktop, use nano command line editor if you don’t know which to use.
When the file opens, replace line 34 (as the error indicates) it = et.getiterator(‘iso_3166_entry’) with it = et.iter(‘iso_3166_entry’) and save the file.
For nano text editor, press Ctrl+X, then type y and hit Enter to save the change.
Finally, open “Software & Updates” or “Software Sources” and choose Download from ‘Other …’, then select or let it automatically choose the best download server for your desktop.
Select Best Download Server from Command Line:
For Debian server without GUI, you can use the command line tool
apt-mirror-updater to change the apt download mirror.
Firstly, connect to the command console and run command to install the pip installer:
sudo apt update && sudo apt install python3-pip
Next, run command to install the tool:
pip3 install apt-mirror-updater
Once installed, use the command to list available mirrors:
NOTE: since the package was installed in local directory without sudo, you may run .local/bin/apt-mirror-updater instead of apt-mirror-updater if “.loca/bin” is not in your path! So the command can be:
In the output mirrors, you can choose one to use via command:
apt-mirror-updater -c "http://ftp.us.debian.org/debian"
Replace the URL as you prefer. Also add ‘.local/bin’ at the beginning if required.
For choice, you can select the best download mirror via command:
It will check the network speed for each server and choose the best one automatically. For more details, see HERE.