optimus-manager: importlib.metadata.PackageNotFoundError: Command runtime error

Describe the bug I’ve just installed Arch and setup the Nvidia driver. Everything seems fine on my old system, but I had this error today.

Steps to reproduce Run optimus-manager an error occurred:

Traceback (most recent call last):
File "/usr/bin/optimus-manager", line 9, in <module>
for entry_point in distribution('optimus-manager==1.3').entry_points:
File "/usr/lib/python3.8/importlib/metadata.py", line 504, in distribution
return Distribution.from_name(distribution_name)
File "/usr/lib/python3.8/importlib/metadata.py", line 177, in from_name
raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: optimus-manager==1.3

System info

  • ArchLinux (dkms kernel)
  • KDE
  • SDDM
  • Occurred in both versions (optimus-manager and optimus-manager-git)
  • Default settings

Logs Unfortunately, I can’t run optimus-manager command. So, here the log that I can provides: /var/log/optimus-manager/switch/

[30] INFO: # Xorg pre-start hook
[30] INFO: Previous state was: {'type': 'pending_pre_xorg_start', 'requested_mode': 'intel', 'current_mode': None}
[30] INFO: Requested mode is: intel
[30] INFO: Checking for GDM display servers
[1917] INFO: Available modules: ['nouveau', 'nvidia', 'nvidia_drm', 'nvidia_modeset', 'nvidia_uvm']
[1917] INFO: Unloading modules ['nvidia_drm', 'nvidia_modeset', 'nvidia_uvm','nvidia'] (if loaded)
[1945] INFO: Loaded extra Intel Xorg options (0 lines)
[1946] INFO: Loaded extra Intel Xorg options (0 lines)
[1947] INFO: Writing to /etc/X11/xorg.conf.d/10-optimus-manager.conf
[1947] INFO: Writing state {'type': 'pending_post_xorg_start', 'switch_id': '20200616T083907', 'requested_mode': 'intel'}
[1947] INFO: Xorg pre-start hook completed successfully.

/var/log/optimus-manager/daemon/

[43] INFO: # Daemon pre-start hook
[43] INFO: Removing /etc/X11/xorg.conf.d/10-optimus-manager.conf (if present)
[47] INFO: Startup mode is: intel
[47] INFO: Writing state {'type': 'pending_pre_xorg_start', 'requested_mode':'intel', 'current_mode': None}
[47] INFO: Daemon pre-start hook completed successfully.
[48] INFO: Calling Xorg pre-start hook.
[3] INFO: # Commands daemon
[4] INFO: Opening UNIX socket
[4] INFO: Awaiting commands
[303132] INFO: Received command : {
"args": {
"mode": "nvidia"
},
"type": "switch"
}

[303133] INFO: Writing requested GPU mode nvidia
[303133] ERROR: Invalid command  "{
"args": {
"mode": "nvidia"
},
"type": "switch"
}
" ! Key error : 'current_mode'
[372076] INFO: Received command : {
"args": {
"content": "[intel]\nDRI=3\naccel=\ndriver=modesetting\nmodeset=yes\ntearfree=\n\n[nvidia]\nDPI=96\nPAT=yes\nallow_external_gpus=no\nignore_abi=no\nmodeset=yes\noptions=overclocking\n\n[optimus]\nauto_logout=yes\npci_power_control=no\npci_remove=no\npci_reset=no\nstartup_auto_battery_mode=intel\nstartup_auto_extpower_mode=nvidia\nstartup_mode=intel\nswitching=acpi_call\n"
},
"type": "user_config"
}

[372076] INFO: Replacing user config at /etc/optimus-manager/optimus-manager.conf with provided content
[372077] INFO: Received command : {
"args": {
"path": ""
},
"type": "temp_config"
}

[372077] INFO: Removing temporary config file path
[957398] INFO: Process stop requested
[957398] INFO: Closing and removing the socket...
[957398] INFO: Goodbye !

EDIT: I’m using optimus-manager-qt to try switching from Intel to NVIDIA but had no luck. Additional information for my packages:

## NVIDIA
local/nvidia-dkms 440.82-2
local/nvidia-settings 440.82-1
local/nvidia-utils 440.82-2

## OpenGL
local/lib32-mesa 20.1.1-2
local/mesa 20.1.1-1

For python packages and its pip list: Hastebin

Kernel: 5.7.2-zen1-1-zen

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 6
  • Comments: 15 (6 by maintainers)

Most upvoted comments

I have the exact same error after a fresh install yesterday! All packages are up-to-date. I did everything as always. Gnome + gdm.

Kernel: 5.7.2-arch1-1

nvidia: nvidia 440.82-21 nvidia-lts 1:440.82-21 nvidia-utils 440.82-2

intel: xf86-video-intel 1:2.99.917+908+g7181c5a4-1

The only thing that is different is /var/log/optimus-manager/daemon

[31] INFO: # Daemon pre-start hook
[31] INFO: Removing /etc/X11/xorg.conf.d/10-optimus-manager.conf (if present)
[33] INFO: Startup mode is: intel
[33] INFO: Writing state {'type': 'pending_pre_xorg_start', 'requested_mode': '>
[33] INFO: Daemon pre-start hook completed successfully.
[33] INFO: Calling Xorg pre-start hook.
[1] INFO: # Commands daemon
[1] INFO: Opening UNIX socket
[1] INFO: Awaiting commands
[5174398] INFO: Process stop requested
[5174398] INFO: Closing and removing the socket...
[5174398] INFO: Goodbye !

I had the same problem. Fixed it in this order:

  • uninstall optimus-manager-git and optimus-manager-qt
  • delete the pamac cache
  • install optimus-manager (not the optimus-manager-git package) and optimus-manager-qt

DE-Gnome/Kernel 5.15 Manjaro

Does python -c "import optimus_manager" return any error ?

No, it does not show anything.

And thanks to @Jerrs for mentioning the workaround for this problem!

EDIT: These (console_script) files also using distribution('optimus-manager==1.3') instead of distribution('optimus-manager'):

/usr/bin/prime-switch
/usr/bin/prime-offload

Hi. I have the exact problem like @KennFatt and I am also on archlinux.

I perform clean installation from https://aur.archlinux.org/packages/optimus-manager-git and still nothing. But I have looked into code of /usr/bin/optimus-manager and I am not expert in python (I have written 20 short scripts and I was very happy 😄) so don’t take it as silly question.

Why is there distribution('optimus-manager==1.3').entry_points?

If I delete ==1.3 optimus-manager works like magic.

Whole script of /usr/bin/optimus-manager here:

#!/usr/bin/python3
# EASY-INSTALL-ENTRY-SCRIPT: 'optimus-manager==1.3','console_scripts','optimus-manager'
import re
import sys
from importlib.metadata import distribution

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    for entry_point in distribution('optimus-manager==1.3').entry_points:
        if entry_point.group == 'console_scripts' and entry_point.name == 'optimus-manager':
            sys.exit(entry_point.load()())

And version is 1.3:

Python 3.8.3 (default, May 17 2020, 18:15:42) 
[GCC 10.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from importlib.metadata import distribution
>>> distribution("optimus-manager").version
'1.3'