Score:0

Pyglossary seemed to install but won't run - error message - what next?

sh flag

I am new to Linux and also to Python. I am trying to run Pyglossary on Python 3.10.6 (preinstalled) on ubuntu 22.04.1.

I installed it using pip (pip install --upgrade pyglossary). There was a warning that it had defaulted to a user installation and that /home/linux/.local/bin wasn't on the path. I added it to the path.

When I try to run it I get the following error message:

[CRITICAL] Traceback (most recent call last):
  File "/home/linux/.local/bin/pyglossary", line 8, in <module>
    sys.exit(main())
  File "/home/linux/.local/lib/python3.10/site-packages/pyglossary/ui/main.py", line 790, in main
    sys.exit(0 if ui_module.UI().run(**runKeywordArgs) else 1)
  File "/home/linux/.local/lib/python3.10/site-packages/pyglossary/ui/ui_gtk.py", line 962, in __init__
    screenW, screenH = getWorkAreaSize()
  File "/home/linux/.local/lib/python3.10/site-packages/pyglossary/ui/ui_gtk.py", line 88, in getWorkAreaSize
    rect = monitor.get_workarea()
AttributeError: 'NoneType' object has no attribute 'get_workarea'

I had previously tried to install it using both pip and sudo apt commands but later ran apt remove and pip uninstall so hopefully that's not connected.

I have no idea what to do next - any advice?

Score:0
fm flag

I solved it as follows: Open with an editor this file: /home/linux/.local/lib/python3.10/site-packages/pyglossary/ui/ui_gtk.py

go to line 88 and change this function a little.

def getWorkAreaSize():
    display = gdk.Display.get_default()
    try:
      monitor = display.get_primary_monitor()
      rect = monitor.get_workarea()
      return rect.width, rect.height
    except:
      monitor = display.get_monitor_at_point(1,1)     
      rect = monitor.get_workarea()
      return rect.width, rect.height

The values rect.width and rect.height are not set by the original function display.get_workarea().

Most likely this is caused because you (at least I) use a build-in screen. Are you also using a laptop? They have a build-in screen setting. I think the setting for a primary monitor does not exists, unless you attach your laptop to an external monitor (my 4 cents)

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.