This simple tutorial shows how to fix the launching issue for TypeCatcher in Ubuntu 22.04 or other Linux with Python 3.9 & higher.
TypeCatcher is a simple GTK application to download and install Google webfonts for off-line use. The app is available to install in Ubuntu Software for all current Ubuntu releases. However, it does not launch in Ubuntu since 21.10.
When trying to launch it from command line, it outputs something like this:
Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/typecatcher_lib/Application.py”, line 30, in on_activate
self.window = TypeCatcherWindow.TypeCatcherWindow()
File “/usr/lib/python3/dist-packages/typecatcher_lib/Window.py”, line 47, in __new__
builder = get_builder(‘TypeCatcherWindow’)
File “/usr/lib/python3/dist-packages/typecatcher_lib/helpers.py”, line 44, in get_builder
File “/usr/lib/python3/dist-packages/typecatcher_lib/Builder.py”, line 86, in add_from_file
ele_widgets = tree.getiterator(“object”)
AttributeError: ‘ElementTree’ object has no attribute ‘getiterator’
The issue is because of the removal of
getiterator() methods from xml.etree.ElementTree module in Python 3.9, which was deprecated since Python 3.2.
As the announcement indicates, simply use
iter() method instead will fix the issue.
Methods getchildren() and getiterator() of classes ElementTree and Element in the ElementTree module have been removed. They were deprecated in Python 3.2. Use iter(x) or list(x) instead of x.getchildren() and x.iter() or list(x.iter()) instead of x.getiterator().
1. First, search for and open a terminal window from either start menu or ‘Activities’ overview depends on your desktop environment.
2. When terminal opens, run command to edit the file that contains the ‘getiterator()’ method (see the first screenshot). In the case, it’s “/usr/lib/python3/dist-packages/typecatcher_lib/Builder.py”.
sudo gedit /usr/lib/python3/dist-packages/typecatcher_lib/Builder.py
replace gedit to your favorite text editor, or use nano command line editor that works in most Linux.
3. When files opens, find out and replace tree.getiterator with tree.iter.
For Gedit text editor, just go to menu, click open ‘Find and Replace’ dialog. Finally, insert tree.getiterator as ‘Find’, and ‘tree.iter‘ as ‘Replace with’, then click on ‘Replace All’ button.
For nano text editor, press Alt+R when the file opens in terminal window. Then type tree.getiterator when it indicates ‘Search (to replace)’, hit Enter, and insert tree.iter when prompts ‘Replace with’. Finally, hit Enter and type y. Or, just use arrow keys to find and replace the keyword (there are 2) manually. And, press Ctrl+x, type y, and hit Enter to save changes.
After saving the file, try to launch it either from ‘Activities’ overview or command line, and enjoy!
Leave a Reply