bayasdev / envycontrol

Easy GPU switching for Nvidia Optimus laptops under Linux
MIT License
1.33k stars 62 forks source link

Solved - [BUG] Envycontrol not working after Python 3.12 update #165

Closed luciorgomes closed 4 months ago

luciorgomes commented 7 months ago

Describe the bug Envycontrol don't run after python 3.12 update on Endeavour (Arch based)

To Reproduce Steps to reproduce the behavior:

  1. Run sudo envycontrol -s nvidia
  2. Error: Traceback (most recent call last): File "/usr/lib/python3.12/importlib/metadata/init.py", line 397, in from_name return next(cls.discover(name=name)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/bin/envycontrol", line 33, in sys.exit(load_entry_point('envycontrol==3.4.0', 'console_scripts', 'envycontrol')()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/bin/envycontrol", line 22, in importlib_load_entry_point for entry_point in distribution(dist_name).entry_points ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/importlib/metadata/init.py", line 862, in distribution return Distribution.from_name(distribution_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/importlib/metadata/init.py", line 399, in from_name raise PackageNotFoundError(name) importlib.metadata.PackageNotFoundError: No package metadata was found for envycontrol

System Information:

overwrite00 commented 7 months ago

Idem on Garuda Linux with KDE 6/ Kernel 6.8.7-zen1-1-zen

bayasdev commented 7 months ago

Arch Linux changed something on their side, will take a look and thanks for reporting!

bayasdev commented 7 months ago

@luciorgomes @overwrite00 if you uninstall envycontrol, clear cache and install it again does it work?

I remember experiencing a similar issue each time Arch Linux did a major Python upgrade.

overwrite00 commented 7 months ago

@luciorgomes @overwrite00 if you uninstall envycontrol, clear cache and install it again does it work?

I remember experiencing a similar issue each time Arch Linux did a major Python upgrade.

I removed envycontrol, cleared cache and installed again. Upon reboot everything works perfectly. Thanks and great work 😉 💪

bayasdev commented 7 months ago

@luciorgomes @overwrite00 if you uninstall envycontrol, clear cache and install it again does it work?

I remember experiencing a similar issue each time Arch Linux did a major Python upgrade.

I removed envycontrol, cleared cache and installed again. Upon reboot everything works perfectly. Thanks and great work 😉 💪

Amazing @overwrite00, do you mind sharing the exact commands in order to update the README? 😉

overwrite00 commented 7 months ago

No problem. The commands to type in your terminal are the following:

sudo pacman -R envycontrol #uninstall envycontrol
sudo pacman -Sc #clear package cache
sudo pacman -Sy envycontrol #install envycontrol

Procedure performed successfully on Garuda Linux.

luciorgomes commented 7 months ago

Thanks @bayasdev @overwrite00 ! It's ok now.

meduk0 commented 7 months ago

on vanilla arch and endeavouros you need to rm -r $HOME/.cache/paru/clone/envycontrol && sudo rm /usr/bin/{netaddr , tqdm} after sudo pacman -Rns envycontrol as it can cause : error: failed to commit transaction (conflicting files) python-netaddr: /usr/bin/netaddr exists in filesystem python-tqdm: /usr/bin/tqdm exists in filesystem Errors occurred, no packages were upgraded. also there is no reason for pacman -Sc NOTE :it is a problem with allmost every python 3.12 pkgs on arch @bayasdev

kpa28-git commented 7 months ago

You can also do this to fix it: paru -S --rebuild envycontrol.

This problem happens with AUR packages depending on python after major python version updates occur. I have a pacman hook to warn me of these cases, but I kind of wish there was a graphics card switcher not written in python for this reason (eg in shell, rust, go, etc).

At least with envycontrol (because it's not service based) these problems won't break my system like they did with optimus-manager

klmcwhirter commented 6 months ago

FYI - for future readers - I tend to use a Python venv for all software that I rely upon and not the system installation. I.e., I do not install any pip packages globally.

PDM (https://pdm-project.org/) can help deal with duplicate package installs across Python apps to minimize filesystem footprint.

Just realize that the root user will need its own cache as well as your login user. So not perfect (yet), but it helps a lot.

Kudos to @bayasdev for his experience with the matrix of variables people are exposed to!

bayasdev commented 4 months ago

Closing due to inactivity