Apparmor ModuleNotFoundError: No module named 'notify2'

Hello,

I am trying to get notifications to work on apparmor. That is the last thing I haven’t figured out and couldn’t find anything on this forum nor the arch wiki on how to solve it.

Error message:

[magician@intel-manjaro-kde ~]$ sudo aa-notify
Traceback (most recent call last):
File “/usr/bin/aa-notify”, line 38, in
import notify2
ModuleNotFoundError: No module named ‘notify2’

There is no separate apparmor notify package in the pamac store so it must be a part of the apparmor package?
I have followed this wiki guide:

https://wiki.archlinux.org/title/AppArmor#Installation

At the: ‘‘Create desktop launcher with the below content:’’ part I could not find the specified location so I used the following location:

/home/magician/.config/autostart/

Then I made a file called: apparmor-notify.desktop. It’s content is such as described in the wiki article.

Can someone shine some light on this error message?

Greetings.

Try installing python-notify2 and python-psutil:

$ sudo pacman -Syu python-notify2 python-psutil --asdeps

see optional dependencies of apparmor:

Optional Deps   : perl: for perl bindings
                  python-notify2: for aa-notify
                  python-psutil: for aa-notify
                  ruby: for ruby bindings

Hi,

You are fast. I did install python-notify2 and after a reboot you already responded haha. No error message this time with:

    [magician@intel-manjaro-kde ~]$ sudo aa-notify
    [sudo] wachtwoord voor magician: 
    usage: aa-notify [-h] [-p] [--display DISPLAY] [-f FILE] [-l] [-s NUM] [-v] [-u USER] [-w NUM] [--debug]
    Display AppArmor notifications or messages for DENIED entries.
    optional arguments:
      -h, --help            show this help message and exit
      -p, --poll            poll AppArmor logs and display notifications
      --display DISPLAY     set the DISPLAY environment variable (might be needed if sudo resets $DISPLAY)
      -f FILE, --file FILE  search FILE for AppArmor messages
      -l, --since-last      display stats since last login
      -s NUM, --since-days NUM
                            show stats for last NUM days (can be used alone or with -p)
      -v, --verbose         show messages with stats
      -u USER, --user USER  user to drop privileges to when not using sudo
      -w NUM, --wait NUM    wait NUM seconds before displaying notifications (with -p)
      --debug               debug mode

I also changed apparmor-notify.desktop to apparmor-notify.desktop.sh.

And I get the following output with:

[magician@intel-manjaro-kde ~]$ pgrep -ax aa-notify
2161 /usr/bin/python3 /usr/bin/aa-notify -p

I am suppose to get (a lot off) notifications displayed according to the wiki, but so far none… Using firefox with firetools now. So far so good??
Is there a way to test a notification? Have read it somewhere but can’t find it anymore.

Thank you.

Tip: When pasting terminal output on Discourse forums, one can either…

  • Highlight it and use the Preformatted text </> toolbar button, not the Blockquote " button

  • Add three backticks ` above and below the text (Markdown):

    ```
    text
    ```

  • Use HTML:

    <pre><code>
    text
    </pre></code>

Please edit your posts accordingly.

As @Yochanan pointed out to me: install those dependecies as dependencies (use --asdeps switch). I’ve edited my post accordingly.
If you just need to mark them now after installing, use:

$ sudo pacman -D --asdeps python-notify2 python-psutil

I’m not sure what that’s supposed to accomplish.

The wiki says: you could get alot of notifications depending on configuration.
Thats slightly different.

Will do. Thank you.

Update.
After removing the .sh extension on apparmor-notify.desktop it works as it should. After reboot:

[magician@intel-manjaro-kde ~]$ pgrep -ax aa-notify
1857 /usr/bin/python3 /usr/bin/aa-notify -p -s 1 -w 60 -f /var/log/audit/audit.log

And once again you beat me to it :slight_smile: