autokey / autokey

AutoKey, a desktop automation utility for Linux and X11.

Home Page:https://autokey.github.io/index.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Autokey failing to launch after system upgrade — ModuleNotFoundError: No module named 'autokey.model.script'

rushvora opened this issue · comments

Edit: The solution to this problem is to reinstall autokey and autokey-common explicitly, and select the option to cleanBuild both. More info can be found in this answer below — #851 (comment)


AutoKey is a Xorg application and will not function in a Wayland session. Do you use Xorg (X11) or Wayland?

Xorg

Has this issue already been reported?

  • I have searched through the existing issues.

Is this a question rather than an issue?

  • This is not a question.

What type of issue is this?

Crash/Hang/Data loss

Choose one or more terms that describe this issue:

  • autokey triggers
  • autokey-gtk
  • autokey-qt
  • beta
  • bug
  • critical
  • development
  • documentation
  • enhancement
  • installation/configuration
  • phrase expansion
  • scripting
  • technical debt
  • user interface

Which Linux distribution did you use?

EndeavourOS Linux x86_64
Kernel: 6.2.13-arch1-1
DE: Plasma 5.27.4
WM: KWin

Which AutoKey GUI did you use?

Qt

Which AutoKey version did you use?

0.96.0-4

How did you install AutoKey?

By running yay -S autokey-qt.

Can you briefly describe the issue?

I upgraded the packages, and after rebooting, AutoKey doesn't launch anymore. It's been working just fine for the past year. It's crashing on launching. Immediately after running the system upgrade, the error message was

❯ autokey-qt                                                                                                                          
Traceback (most recent call last):
  File "/usr/bin/autokey-qt", line 5, in <module>
    from autokey.qtui.__main__ import Application
ModuleNotFoundError: No module named 'autokey'

Then, I decided to reinstall it and cleanBuild it. After doing so, the error message is

❯ autokey-qt
Traceback (most recent call last):
  File "/usr/bin/autokey-qt", line 5, in <module>
    from autokey.qtui.__main__ import Application
  File "/usr/lib/python3.11/site-packages/autokey/qtui/__main__.py", line 23, in <module>
    from autokey.qtapp import Application
  File "/usr/lib/python3.11/site-packages/autokey/qtapp.py", line 31, in <module>
    import autokey.model.script
ModuleNotFoundError: No module named 'autokey.model.script'

I've also created a pastebin listing all the packages that were upgraded, I'm assuming one/some of the package upgrades is resulting in this issue (python 3.10 to 3.11?). https://pastebin.com/xYXkQA5y

Can the issue be reproduced?

Always

What are the steps to reproduce the issue?

Try launching autokey via autokey-qt command in the shell, in Arch Linux or EndeavourOS with the latest packages installed.

Do let me know how I can be of any help, I'll try my best.

commented

@BlueDrink9 I know you're busy, but I believe you're the only one of us who uses arch.

Same issue after python upgrade on arch/xorg - autokey-gtk.

Experiencing the same issue, launching from the terminal gives me this error:

Traceback (most recent call last):
File "/usr/bin/autokey-qt", line 5, in <module>
from autokey.qtui.__main__ import Application
ModuleNotFoundError: No module named 'autokey'
commented

I get the same output, with or without the flag. Python 3.11.3-1.

Traceback (most recent call last): File "/usr/bin/autokey-gtk", line 5, in <module> from autokey.gtkui.__main__ import main ModuleNotFoundError: No module named 'autokey'

Is there an error earlier in the log? Can you launch with the -l flag (verbose) and post the output? You're on python 3.11 as well?

On Thu, May 4, 2023, 05:49 Alessadro Parisi @.> wrote: Experiencing the same issue, launching from the terminal gives me this error: Traceback (most recent call last): File "/usr/bin/autokey-qt", line 5, in from autokey.qtui.main import Application ModuleNotFoundError: No module named 'autokey' — Reply to this email directly, view it on GitHub <#851 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANA2OGUT7ABIJ2K2C6IS6TXEN3Q7ANCNFSM6AAAAAAXVDVCKU . You are receiving this because you are subscribed to this thread.Message ID: @.>

I can confirm, I see nothing but the same message as above

commented

I did a VM install of Endeavour OS with the KDE Plasma desktop and installed autokey via yay -S autokey-qt per the OP here but it looks like everything is working for me.

[sam@endeavour ~]$ uname -a
Linux endeavour 6.3.1-arch1-1 #1 SMP PREEMPT_DYNAMIC Mon, 01 May 2023 17:42:39 +0000 x86_64 GNU/Linux
[sam@endeavour ~]$ python3 --version
Python 3.11.3

I'm not super familiar with Arch variants, any ideas what would be causing it issues in your install but not mine?

Can someone with this issue try running autokey directly from a git clone folder of autokey?

git clone https://github.com/autokey/autokey
cd lib
python3 -m autokey.gtkui -lc 

Or .qtui depending on your preference.

Running autokey directly works for me.

git clone https://github.com/autokey/autokey
cd lib
python3 -m autokey.gtkui -lc

Same, running python3 -m autokey.qtui -lc launches AutoKey successfully.

I think I figured it out. I was looking in the directory mentioned in the error messages, /usr/lib/python3.11/site-packages/. Well, it turns out autokey-0.96.0.dist-info, pep517, and pep517-0.13.0.dist-info were still present in the /usr/lib/python3.10/site-packages directory, and absent from the 3.11/site-packages directory which seems to be the issue? The 3.10/site-packages directory only contains these three folders, the 3.11/site-packages directory contains everything else (a LOT of folders!)

So I decided to run sudo cp -r autokey-0.96.0.dist-info pep517 pep517-0.13.0.dist-info ../../python3.11/site-packages, and then I tried launching AutoKey, but I get the same error message that's there in the OP. I deleted the three folders.

Then, I ran yay -S autokey-common and chose to cleanBuild it (select the [A]ll option), and now AutoKey launches successfully!!

Now, when I check the above mentioned directories, autokey-0.96.0.dist-info has been removed from the python3.10/site-packages directory, and is now in the python3.11/site-packages directory.

I still got this warning

(3/3) Checking which packages need to be rebuilt
foreign	python-pep517

so I ran yay -S python-pep517, but I get the message No AUR package found for python-pep517 there is nothing to do so I guess it's been removed from AUR/Arch repositories.

pep517 pep517-0.13.0.dist-info, these folders are still in /usr/lib/python3.10/site-packages. I'm assuming these aren't required for AutoKey to work.

Edit: I'm assuming @sebastiansam55 could not reproduce the issue, because these folders were correctly installed in the python3.11/site-packages folder, since it was a fresh install. 😅

Thanks @rushvora for the info.

I deleted /usr/lib/python3.10/site-packages/autokey*, reinstalled autokey (cleanBuild) and it works now:

sudo rm -rf /usr/lib/python3.10/site-packages/autokey*
yay -S autokey-gtk autokey-common

Got bunch of warnings in the console for the first run, but now everything looks fine.

warning: could not get file information for usr/lib/python3.10/site-packages/autokey-0.96.0.dist-info/
warning: could not get file information for usr/lib/python3.10/site-packages/autokey-0.96.0.dist-info/LICENSE
warning: could not get file information for usr/lib/python3.10/site-packages/autokey-0.96.0.dist-info/METADATA
...
commented

Glad to hear you were able to figure that out.

So is this a packaging issue? Can one of you open a ticket on the AUR package about it? (if that would be appropriate, not familiar with how that system works)

This is what is happening on the Chaotic AUR repo
Screenshot_20230504-164308_Telegraph.png

Glad to hear you were able to figure that out.

So is this a packaging issue? Can one of you open a ticket on the AUR package about it? (if that would be appropriate, not familiar with how that system works)

I don't have much of an idea either, about AUR packaging or about the way python handles these dependency/package migrations from version to version. 😅

commented

Glad this is getting sorted.

If any of you are so inclined, please feel free to join us on Gitter.

I'm glad this is sorted, too, but I thought I'd jump in and say that some of the instructions above were missing a step.

This:

git clone https://github.com/autokey/autokey
cd lib
python3 -m autokey.gtkui -lc 

Should have been this:

git clone https://github.com/autokey/autokey
cd autokey
cd lib
python3 -m autokey.gtkui -lc 

It's vital that you're inside of the cloned directory and inside of its lib directory. Otherwise, when you run the command in the final line, it will run the currently-installed version of AutoKey instead of the clone.

I do it all the time when I'm testing now. I'll sit inside of the lib directory to test the clone and then cd .. out of it to compare it with the current installation and then cd lib back in again to go back to testing out the clone.

I'm also happy to report that putting all of those steps into a one-liner and sticking that into a clickable shortcut works like a charm. You can keep the shortcut, get rid of the clone, and when you grab another clone later, the shortcut will work for the new clone. Love it.

I stumbled over this issues as well and for me the problem was the yay cache.

There is already an issue in the yay repo for this: Jguer/yay#2153 and especially this comment seems relevant to the problem: Jguer/yay#2153 (comment)

As a workaround you can clear the yay cache and then rebuild the package. After that it should be installed in the correct directory:

# Clearing yay and pacman caches
yay -Sc

# Uninstall the autokey package and its dependencies
yay -Rns autokey-qt

# Rebuild and install the autokey-packages.
yay -S --rebuildtree autokey-qt

I hope this helps.

I still can't run it :(
I tried everything, the error now is different though

Traceback (most recent call last):
File "/usr/bin/autokey-qt", line 5, in <module>
from autokey.qtui.__main__ import Application
File "/usr/lib/python3.11/site-packages/autokey/qtui/__main__.py", line 23, in <module>
from autokey.qtapp import Application
File "/usr/lib/python3.11/site-packages/autokey/qtapp.py", line 31, in <module>
import autokey.model.script
ModuleNotFoundError: No module named 'autokey.model.script'

Edit:
I kinda solved it. I installed autokey with pip install autokey, and it was still not working because of missing dependencies. So I run pip install -r pip-requirements.txt (from a clone I did before) and tried running again, it finally worked!
Now, out of curiosity, I tried reinstalling autokey from the AUR repo again following the instructions posted by @astehlik. And it works from AUR too now!
Now my setup is probably a mess, but as long as it works, and I can continue my activities I won't touch it anymore

Nice. That's such good news. It looks like it was a dependency issue. I'm glad you've got it working.

In case you should ever need it as another alternative, this should also work:

git clone https://github.com/autokey/autokey
cd autokey
cd lib
python3 -m autokey.gtkui -lc 

If it works, the last three lines can be turned into a one-liner that you can put into a shortcut for later use. You can also choose which of those two command-line switches (the -lc part) you want to use or use none if you like.

As an example, the one I use for development in my virtual machine points to an autokey directory on my Desktop and I like the main window to open when I launch AutoKey, so it uses the -c command-line switch and my shortcut looks like this:

cd ~/Desktop/autokey/lib && python3 -m autokey.gtkui -c
commented

@rushvora Is this resolved and can it be closed as completed?

I still can't run it :( I tried everything, the error now is different though

@palexdev did you try astehlik's steps (clearing yay/pacman cache, uninstalling autokey, and then reinstalling with the rebuild option) or what worked for me (reinstalling autokey-common and selecting rebuild all)?

The error you got, is what I got as well, when just reinstalling and rebuilding autokey itself. I had to specifically reinstall autokey-common.

@rushvora Is this resolved and can it be closed as completed?

@josephj11 I imagine other people will face the same issue over the next few months? In any case, it's solved for me.

commented

@rushvora OK. I'll leave this open for a while to make it easier to find. Thanks for your input.

I also got this issue in Arch Linux (Endeavour OS). When I ran which autokey-gtk on the terminal I got:

 souto@eos  ~  autokey-gtk       
Traceback (most recent call last):
  File "/usr/bin/autokey-gtk", line 5, in <module>
    from autokey.gtkui.__main__ import main
  File "/usr/lib/python3.11/site-packages/autokey/gtkui/__main__.py", line 4, in <module>
    from autokey.gtkapp import Application
  File "/usr/lib/python3.11/site-packages/autokey/gtkapp.py", line 17, in <module>
    import autokey.dbus_service
ModuleNotFoundError: No module named 'autokey.dbus_service'

I think I could fix it with pip install autokey. Not sure that's the right or best approach but the GUI application now opens when I open it from rofi and seems to grab my config data fine.

commented

@msoutopico Let us know if you have further issues. Hopefully, the yay problem will be fixed by Arch shortly.

Welcome to the AutoKey community. Be sure to check out our wiki for helpful articles and lots of example scripts.

@msoutopico Run yay -S autokey-common, and while reinstalling it, select the option to cleanBuild it. It should launch without any issues now.

I can confirm the issue has been resolved for the Chaotic AUR packages. Just tested on my laptop.
I used @astehlik instructions to clean, remove and then install
However, since Chaotic AUR packages are already built, we don't have the rebuildtree nor the cleanBuild flags

@josephj11, can we get some new labels, like os-aur or os-arch or os-debian or os-mint or os-ubuntu, etc., so that they can be used to narrow down searches by operating system? This seems like an important resolution that others who use these operating systems may also have need of.

commented

@Elliria Sure if you really want to use them. The more I think about it, the less I like the idea.

What's the difference between os-aur and os-arch?

Also os-suse os-fedora or maybe os-redhat for all their flavors (including Centos). There are lots of others os-pop os-puppy ... too many. os-gentoo mx antix zorin - I keep thinking of more of them.

There have to be enough instances with a particular tag to make it worthwhile (and they're more to scroll through when looking through the tags to assign them.) We only have one table of labels and they aren't hierarchical so you can't have colapsed sections...

The issues search field can search on anything now, so you can find them without explicit labels.

And, when do you assign them? I would want it to be only when the OS seems to be part of the problem - not just what the user happens to be using. That's a bunch more thinking when assigning labels (done mostly by me).

I'll agree that it would be too many new labels after all and a targeted search could be done to find the issue(s) anyway, so I take it back. As for the os-aur and os-arch, I have no idea. That's not my world and I just saw both mentioned above.

For me a simple uninstall & install with paru worked just fine.

I stumbled over this issues as well and for me the problem was the yay cache.

There is already an issue in the yay repo for this: Jguer/yay#2153 and especially this comment seems relevant to the problem: Jguer/yay#2153 (comment)

As a workaround you can clear the yay cache and then rebuild the package. After that it should be installed in the correct directory:

# Clearing yay and pacman caches
yay -Sc

# Uninstall the autokey package and its dependencies
yay -Rns autokey-qt

# Rebuild and install the autokey-packages.
yay -S --rebuildtree autokey-qt

It worked! Tanks!!!