davidhi7 / ddcci-plasmoid

KDE Plasma widget to adjust the brightness of multiple external monitors
MIT License
390 stars 11 forks source link

ModuleNotFoundError #71

Closed noyannus closed 4 months ago

noyannus commented 4 months ago

I keep getting ModuleNotFoundError. Not sure if this is related to #54.

I tried the installation of ddcci_plasmoid_backend via pipx (pip did't work, that is OK for me), two times, as root and as normal user.

It does work when run as root:

localhost# ~/.local/bin/ddcci_plasmoid_backend detect
{"command": "detect", "value": []}

Run as user, it throws an error because of a lock file:

localhost% ~/.local/bin/ddcci_plasmoid_backend detect
Traceback (most recent call last):
File "/home/me/.local/bin/ddcci_plasmoid_backend", line 8, in <module>
sys.exit(main())
^^^^^^
<snip>
File "/home/me/.local/share/pipx/venvs/ddcci-plasmoid-backend/lib64/python3.11/site-packages/fasteners/process_lock.py",line 114, in _do_open
self.lockfile = open(self.path, 'a')
^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: b'/tmp/ddcci_plasmoid_backend-me.lock'

The backend executable command is set in two widgeds as python3 -m /home/me/.local/pipx/venvs/ddcci-plasmoid-backend/bin/ddcci_plasmoid_backend detect and python3 -m /root/.local/pipx/venvs/ddcci-plasmoid-backend/bin/ddcci_plasmoid_backend detect, respectively.

I think all files and links are where they should be and have the required permissions:

Screenshot_20240221_114533

Still there is this No module named '/home/me/' or ... '/root/' error.

What am I doing wrong? Thankful for every hint.

davidhi7 commented 4 months ago

You should generally not install the backend for the root user, normal user permissions should always be sufficient.

What are the permission settings on the /tmp directorry? Run ls -lah / | grep tmp to print them. If the output doesn't start with drwxrwxrwt, the /tmp permissions might be configured wrongly.

Also, when using pipx, the backend executable command should be ~/.local/bin/ddcci_plasmoid_backend. This part of the install guide is definitely lacking currently.

noyannus commented 4 months ago

Thanks for the quick reply!

Removed the root install. That simplifies the bug hunt.

localhost# echo; ls -l  $(find /home/*  /root/ -xdev  -iname  ddcci_plasmoid_backend) | sed 's/xx/me/g'

lrwxrwxrwx 1 me me  82 Feb 21 10:16 /home/me/.local/bin/ddcci_plasmoid_backend -> /home/me/.local/share/pipx/venvs/ddcci-plasmoid-backend/bin/ddcci_plasmoid_backend
-rwxr-xr-x 1 me me 280 Feb 21 10:16 /home/me/.local/share/pipx/venvs/ddcci-plasmoid-backend/bin/ddcci_plasmoid_backend

/home/me/.local/share/pipx/venvs/ddcci-plasmoid-backend/lib/python3.11/site-packages/ddcci_plasmoid_backend:
total 32
-rw-r--r-- 1 me me 6200 Feb 21 10:16 ddcci.py
-rw-r--r-- 1 me me  927 Feb 21 10:16 ddcci_test.py
-rw-r--r-- 1 me me 1078 Feb 21 10:16 __init__.py
-rw-r--r-- 1 me me 5013 Feb 21 10:16 __main__.py
-rw-r--r-- 1 me me 3318 Feb 21 10:16 Node.py
-rw-r--r-- 1 me me 3261 Feb 21 10:16 Node_test.py
drwxr-xr-x 1 me me  280 Feb 21 10:16 __pycache__

~/.local/bin/ddcci_plasmoid_backend is a link to ~/.local/share/pipx/venvs/ddcci-plasmoid-backend/bin/ddcci_plasmoid_backend. That should only matter if group and other require write permissions. But then, the widget ought to work with the path you posted above.

/tmp is OK:

localhost# ls -lah / | grep tmp
drwxrwxrwt  18 root root  420 Feb 22 11:58 tmp

The user installations of the backend do work.

localhost% ~/.local/bin/ddcci_plasmoid_backend detect
{"command": "detect", "value": []}
localhost% ~/.local/share/pipx/venvs/ddcci-plasmoid-backend/bin/ddcci_plasmoid_backend detect
{"command": "detect", "value": []}
localhost%

Even with copy-pasting the command path from your post (to make sure I don't introduce a typo), the result of the widget is the same.

It's puzzling that the widget complains about a module not found, and for its name gives the home folder of the user (or root, as it were).

davidhi7 commented 4 months ago

Backend executable command must be only ~/.local/bin/ddcci_plasmoid_backend without any python executables before, because ~/.local/bin/ddcci_plasmoid_backend is not a python module but a script created by pipx that executes runs the actual python module. The No module named /home/you part is indeed puzzling, I assume your username doesn't contain a space or any other unusual characters?

noyannus commented 4 months ago

Backend executable command must be only ~/.local/bin/ddcci_plasmoid_backend without any python executables before

Ah! Getting closer... Now I see "No monitors detected", also after refresh. ddcutil detect returns Invalid display both for internal and external display.

localhost# ddcutil detect
Invalid display
I2C bus:  /dev/i2c-12
DRM connector:           card1-eDP-1
EDID synopsis:
Mfg id:               BOE - BOE
Model:
Product code:         2399  (0x095f)
Serial number:e user name: tests were done on a user with a name of two lower case characters, and before with "root". No s
Binary serial number: 0 (0x00000000)
Manufacture year:     2019,  Week: 23
DDC communication failed
This is an eDP laptop display. Laptop displays do not support DDC/CI.

Invalid display
I2C bus:  /dev/i2c-14
DRM connector:           card1-DP-2
EDID synopsis:
Mfg id:               GSM - Goldstar Company Ltd (LG)
Model:                W2261
Product code:         22223  (0x56cf)
Serial number:
Binary serial number: 274241 (0x00042f41)
Manufacture year:     2009,  Week: 2
DDC communication failed

But... It is possible to control internal brightness with the plasma-screendimmer applet (aka Display Brightness 0.9, the author in its info pane is different but the link points there and the interface looks identical -???), and both screens with Brighty 0.3 (although the interface is somewhat broken).


Re user name: Tests were done as a user with a name of two lower case characters, and before with "root". No spaces, nothing beyond plain ASCII.


I forgot to give system details in the op, sorry:

Operating System: openSUSE Tumbleweed 20240218 KDE Plasma Version: 5.27.10 KDE Frameworks Version: 5.115.0 Qt Version: 5.15.12 Kernel Version: 6.7.5-1-default (64-bit) Graphics Platform: X11 Processors: 8 × 11th Gen Intel

davidhi7 commented 4 months ago

The two widgets you linked adjust the brightness on a software level (making all colours darker, with negative impact on the monitor's colour gamut).

This widget uses DDC/CI to control the physical brightness of the monitor backlight (equivalent to changing the brightness in the monitors on screen menu), thus this widget only works if the monitors support DDC/CI. Internal displays generally don't support this, for those you can simply use the widget built into KDE Plasma.

Newer external monitors usually support DDC/CI, however older like yours sometimes don't. Check if DDC/CI is enabled in the settings of your monitor. If you use an NVIDIA gpu, follow the documentation: https://www.ddcutil.com/nvidia/.

noyannus commented 4 months ago

Thank you for the explanation, that was really not on my radar. Time to upgrade, then.

Closing as resolved.