[SOLVED] Typecatcher doesn't work [json.loads()] on Arch [AUR]

Typecatcher is an awesome tool to download and use Google Fonts offline, It's available on AUR & maintained by chelqo as on 8th April 2017.

It might have some dependency problems in your distribution so first we need to make sure that, we have all dependencies, please note that Typecatcher package requires following packages as dependencies, which are not installed as dependencies while installing from AUR in some cases.

In that case you have to get those dependencies installed, on your own. In my case following dependencies were missing

python-gobject 
webkitgtk


I installed following versions of the missing dependencies to get typecatcher working.

python-gobject  3.22.0-2
webkitgtk  2.4.11-4


Commands to install missing dependencies.
sudo pacman -S python-gobject
sudo pacman -S webkitgtk
Even after installing the missing dependencies typecatcher refused to run on my system and displayed the following error message.
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/typecatcher_lib/Application.py", line 30, in on_activate
    self.window = TypeCatcherWindow.TypeCatcherWindow()
  File "/usr/lib/python3.6/site-packages/typecatcher_lib/Window.py", line 49, in __new__
    new_object.finish_initializing(builder)
  File "/usr/lib/python3.6/site-packages/typecatcher/TypeCatcherWindow.py", line 43, in finish_initializing
    self.fonts = FindFonts()
  File "/usr/lib/python3.6/site-packages/typecatcher/FindFonts.py", line 27, in FindFonts
    fonts = process_json(data)
  File "/usr/lib/python3.6/site-packages/typecatcher/FindFonts.py", line 50, in process_json
    json_data = json.loads(data, "utf-8")
TypeError: loads() takes 1 positional argument but 2 were given
In my case I had to edit two files myself, if you are also getting similar error messages after installing missing dependencies then the following fix is likely to solve your problems.

Run the following command.
sudo nano /usr/lib/python3.6/site-packages/typecatcher/FindFonts.py
 In the def process_json(data):
Add "encoding=" before "utf-8"
Then it should look like this
json_data = json.loads(data, encoding="utf-8")
Use Ctrl X to EXIT and Press "Y" to Confirm then Hit ENTER

After this fix, typecatcher GUI should start. In my case I was getting following error while downloading fonts.
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/typecatcher/TypeCatcherWindow.py", line 243, in on_download_btn_clicked
    DownloadFont(self.font, uri=None)
  File "/usr/lib/python3.6/site-packages/typecatcher/DownloadFont.py", line 31, in DownloadFont
    font_dict = extract_url(font_name)
  File "/usr/lib/python3.6/site-packages/typecatcher/DownloadFont.py", line 61, in extract_url
    json_data = json.loads(str(data), "utf-8")
TypeError: loads() takes 1 positional argument but 2 were given
We have to follow same procedure to fix this error.
Run the following command. 
sudo nano /usr/lib/python3.6/site-packages/typecatcher/DownloadFont.py
In the def extract_url(family):
Add "encoding=" before "utf-8"
Then it should look like this
json_data = json.loads(data, encoding="utf-8")
Use Ctrl X to EXIT and Press "Y" to Confirm then Hit ENTER

After this you should be able to launch typecatcher and install fonts to your system without any errors.

If you found this informative and helpful please leave a comment share this and join our facebook group and like our page (Links in the sidebar)

Comments

  1. Replies
    1. Welcome! Please Share this blog and join our facebook group

      Delete
  2. Thank you, now it works!
    Coud you post the link to this page in the TypeCatcher entry on AUR?
    https://aur.archlinux.org/packages/typecatcher/

    ReplyDelete

Post a Comment

Popular posts from this blog

Site wide CSRF on a popular program

Releasing Flumberbuckets: S3 Bucket Enumeration Tool for Bug Hunters

Installing XFCE & other things on Arch Linux