question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

importlib.metadata.PackageNotFoundError: Command runtime error

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
alexanderwwagnercommented, Jan 4, 2022

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

1reaction
KennFattcommented, Jun 17, 2020

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
Read more comments on GitHub >

github_iconTop Results From Across the Web

PackageNotFound error while executing .exe file made by ...
I solved the problem by using the following command on cmd when running PyInstaller: pyinstaller --onefile --hidden-import=pytorch ...
Read more >
importlib-metadata - PyPI
This package supplies third-party access to the functionality of importlib.metadata including improvements added to subsequent Python versions.
Read more >
Installation Error - prefect version cmd errors - Getting Started
As per Using importlib.metadata — Python 3.10.8 documentation Changed in version 3.10: ... PackageNotFoundError: No package metadata was found for prefect.
Read more >
PyInstaller Documentation - Read the Docs
Open a command prompt/shell window, and navigate to the directory where your .py file is located, then build your app with the following...
Read more >
Install cloud-init - - Alibaba Cloud Documentation Center
Run the following command to check whether cloud-init is installed: ... in from_name raise PackageNotFoundError(name) importlib.metadata.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found