sezanzeb / input-remapper

🎮 ⌨ An easy to use tool to change the behaviour of your input devices.
GNU General Public License v3.0
3.78k stars 155 forks source link

After upgrading python to 3.10 Key-Mapper is not working anymore #231

Closed TheTRCG closed 2 years ago

TheTRCG commented 2 years ago

Installation using deb fails with error code 0, installation using source code and setup.py install does work but the application doesn't launch. A question mark icon shows up on the taskbar for a few seconds before disappearing. Happened after I upgraded my python version from 3.8 to 3.10.

sezanzeb commented 2 years ago

What happens in the console if you run key-mapper-gtk -d?

nasirHo commented 2 years ago

I have the same issue after upgrade python from 3.9 to 3.10.

What happens in the console if you run key-mapper-gtk -d?

> key-mapper-gtk -d
Traceback (most recent call last):
File "/usr/bin/key-mapper-gtk", line 29, in <module>
from keymapper.data import get_data_path
ModuleNotFoundError: No module named 'keymapper'

I installed key-mapper-git using paru on arch. After upgrade python, I have reinstalled key-mapper-git, but the error remained.

sezanzeb commented 2 years ago

Please run

git clone https://github.com/sezanzeb/key-mapper.git
cd key-mapper
python3 setup.py build
python3 setup.py install --root=./installtest
find installtest

and post the output

this is what the pkgbuild is doing https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=key-mapper-git, but without installing it into the system yet

Ah, and python3 setup.py build seems to be redundant

TheTRCG commented 2 years ago

For install test my output is:

installtest/usr
installtest/usr/bin
installtest/usr/bin/key-mapper-control
installtest/usr/bin/key-mapper-helper
installtest/usr/bin/key-mapper-gtk
installtest/usr/bin/key-mapper-service
installtest/usr/share
installtest/usr/share/key-mapper
installtest/usr/share/key-mapper/key-mapper-large.png
installtest/usr/share/key-mapper/key-mapper-autoload.desktop
installtest/usr/share/key-mapper/key-mapper.glade
installtest/usr/share/key-mapper/key-mapper.service
installtest/usr/share/key-mapper/key-mapper.policy
installtest/usr/share/key-mapper/key-mapper.rules
installtest/usr/share/key-mapper/keymapper.Control.conf
installtest/usr/share/key-mapper/key-mapper.desktop
installtest/usr/share/key-mapper/lang
installtest/usr/share/key-mapper/lang/it_IT
installtest/usr/share/key-mapper/lang/it_IT/LC_MESSAGES
installtest/usr/share/key-mapper/lang/it_IT/LC_MESSAGES/key-mapper.mo
installtest/usr/share/key-mapper/lang/sk_SK
installtest/usr/share/key-mapper/lang/sk_SK/LC_MESSAGES
installtest/usr/share/key-mapper/lang/sk_SK/LC_MESSAGES/key-mapper.mo
installtest/usr/share/key-mapper/key-mapper.svg
installtest/usr/share/key-mapper/style.css
installtest/usr/share/polkit-1
installtest/usr/share/polkit-1/actions
installtest/usr/share/polkit-1/actions/key-mapper.policy
installtest/usr/share/applications
installtest/usr/share/applications/key-mapper.desktop
installtest/usr/lib
installtest/usr/lib/udev
installtest/usr/lib/udev/rules.d
installtest/usr/lib/udev/rules.d/key-mapper.rules
installtest/usr/lib/systemd
installtest/usr/lib/systemd/system
installtest/usr/lib/systemd/system/key-mapper.service
installtest/usr/local
installtest/usr/local/lib
installtest/usr/local/lib/python3.8
installtest/usr/local/lib/python3.8/dist-packages
installtest/usr/local/lib/python3.8/dist-packages/key_mapper-1.2.1.egg-info
installtest/usr/local/lib/python3.8/dist-packages/key_mapper-1.2.1.egg-info/top_level.txt
installtest/usr/local/lib/python3.8/dist-packages/key_mapper-1.2.1.egg-info/dependency_links.txt
installtest/usr/local/lib/python3.8/dist-packages/key_mapper-1.2.1.egg-info/requires.txt
installtest/usr/local/lib/python3.8/dist-packages/key_mapper-1.2.1.egg-info/PKG-INFO
installtest/usr/local/lib/python3.8/dist-packages/key_mapper-1.2.1.egg-info/SOURCES.txt
installtest/usr/local/lib/python3.8/dist-packages/keymapper
installtest/usr/local/lib/python3.8/dist-packages/keymapper/paths.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/logger.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/__init__.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/gui
installtest/usr/local/lib/python3.8/dist-packages/keymapper/gui/__init__.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/gui/helper.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/gui/row.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/gui/reader.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/gui/custom_mapping.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/gui/window.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/gui/__pycache__
installtest/usr/local/lib/python3.8/dist-packages/keymapper/gui/__pycache__/__init__.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/gui/__pycache__/window.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/gui/__pycache__/row.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/gui/__pycache__/reader.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/gui/__pycache__/helper.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/gui/__pycache__/custom_mapping.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/system_mapping.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/data.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/mapping.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/user.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/daemon.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/config.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/injection
installtest/usr/local/lib/python3.8/dist-packages/keymapper/injection/consumer_control.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/injection/__init__.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/injection/context.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/injection/injector.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/injection/consumers
installtest/usr/local/lib/python3.8/dist-packages/keymapper/injection/consumers/consumer.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/injection/consumers/__init__.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/injection/consumers/keycode_mapper.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/injection/consumers/event_producer.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/injection/consumers/__pycache__
installtest/usr/local/lib/python3.8/dist-packages/keymapper/injection/consumers/__pycache__/__init__.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/injection/consumers/__pycache__/event_producer.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/injection/consumers/__pycache__/keycode_mapper.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/injection/consumers/__pycache__/consumer.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/injection/macros
installtest/usr/local/lib/python3.8/dist-packages/keymapper/injection/macros/__init__.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/injection/macros/parse.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/injection/macros/macro.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/injection/macros/__pycache__
installtest/usr/local/lib/python3.8/dist-packages/keymapper/injection/macros/__pycache__/macro.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/injection/macros/__pycache__/__init__.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/injection/macros/__pycache__/parse.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/injection/numlock.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/injection/__pycache__
installtest/usr/local/lib/python3.8/dist-packages/keymapper/injection/__pycache__/__init__.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/injection/__pycache__/context.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/injection/__pycache__/numlock.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/injection/__pycache__/injector.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/injection/__pycache__/consumer_control.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/groups.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/presets.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/ipc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/ipc/__init__.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/ipc/pipe.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/ipc/socket.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/ipc/shared_dict.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/ipc/__pycache__
installtest/usr/local/lib/python3.8/dist-packages/keymapper/ipc/__pycache__/__init__.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/ipc/__pycache__/socket.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/ipc/__pycache__/shared_dict.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/ipc/__pycache__/pipe.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/__pycache__
installtest/usr/local/lib/python3.8/dist-packages/keymapper/__pycache__/system_mapping.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/__pycache__/__init__.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/__pycache__/logger.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/__pycache__/user.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/__pycache__/utils.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/__pycache__/presets.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/__pycache__/config.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/__pycache__/data.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/__pycache__/key.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/__pycache__/groups.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/__pycache__/daemon.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/__pycache__/mapping.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/__pycache__/paths.cpython-38.pyc
installtest/usr/local/lib/python3.8/dist-packages/keymapper/utils.py
installtest/usr/local/lib/python3.8/dist-packages/keymapper/key.py
installtest/etc
installtest/etc/dbus-1
installtest/etc/dbus-1/system.d
installtest/etc/dbus-1/system.d/keymapper.Control.conf
installtest/etc/xdg
installtest/etc/xdg/autostart
installtest/etc/xdg/autostart/key-mapper-autoload.desktop

And for key-mapper-gtk -d it's:

Traceback (most recent call last):
  File "/usr/bin/key-mapper-gtk", line 29, in <module>
    from keymapper.data import get_data_path
ModuleNotFoundError: No module named 'keymapper.data'

Same as the other guy

sezanzeb commented 2 years ago

please post

ls /usr/local/lib/

and

python3
import sys
sys.path
TheTRCG commented 2 years ago

python2.7 python3.10 python3.8 ['', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/usr/local/lib/python3.8/dist-packages', '/usr/lib/python3/dist-packages'] I'm on ubuntu so no AUR for me, but Lutris works fine (sorry I saw the notification before it was edited)

saikat0511 commented 2 years ago

Rebuilding the package fixed it for me on arch. Same goes for any other python packages installed from aur.

https://www.reddit.com/r/archlinux/comments/rf6c84/psa_python_310_is_in_core_rebuild_your_aur/

sezanzeb commented 2 years ago

Ok, I'll close this then

TheTRCG commented 2 years ago

@sezanzeb it still isn't working for me though unfortunately. I tried redownloading and using an older package to no effect as well

sezanzeb commented 2 years ago

@TheTRCG That's actually quite weird. /usr/lib/python3.8 is in your sys.path, and it seems to be the place where key-mapper is supposed to be installed to.

Have you tried the manual building and installation via git clone? https://github.com/sezanzeb/key-mapper#ubuntudebian

sudo apt install git python3-setuptools gettext
git clone https://github.com/sezanzeb/key-mapper.git
cd key-mapper && ./scripts/build.sh
sudo apt install ./dist/key-mapper-1.2.1.deb

Please post the output of this if it doesn't work

TheTRCG commented 2 years ago

@sezanzeb The installation works fine, I've done every installation listed on the github readme, the problem is that it doesn't start. The icon and shortcut are added and it launches with a question mark icon and then closes after a second

saikat0511 commented 2 years ago

@TheTRCG I am taking a guess here since I don't use ubuntu. Do you have multiple python3 packages installed? Does the output of python3 --version show 3.10 ?

TheTRCG commented 2 years ago

@saikat0511 I do have multiple python versions installed but the default when using python3 is 3.8.10 so the same that came with my OS

saikat0511 commented 2 years ago

@TheTRCG That might be the cause of your issue. Try changing the default python version to 3.10 with sudo update-alternatives --config python, reboot, clean build and install the package again

TheTRCG commented 2 years ago

@saikat0511 Before I has my default set to 3.10 but it broke another package which needed 3.8, when I had 3.10 key-mapper didn't work, and now that I've switched back to 3.8 it still doesn't. Any way for me to run the program in a debug mode so I can see what the errors causing it to not run are?

sezanzeb commented 2 years ago

@TheTRCG post the output please

mattzab commented 2 years ago

I'm on Arch and have the AUR. I've rebuilt packages multiple times and it still doesn't work. Still shows key-mapper-gtk -d Traceback (most recent call last): File "/usr/bin/key-mapper-gtk", line 29, in <module> from keymapper.data import get_data_path ModuleNotFoundError: No module named 'keymapper.data'

I'm on Python 3.10.1 with no other versions installed.

saikat0511 commented 2 years ago

@mattzab just to make sure, are you clean building the package? Rebuilding with existing build files wont work.

mattzab commented 2 years ago

@saikat0511 As far as I know, yes. yay -Rsu key-mapper-git to remove package and deps, then pacman -Scc to clear all cached package files, followed by yay -Syu key-mapper-git --rebuildtree Same exact error.

sezanzeb commented 2 years ago

@mattzab the key-mapper package should be installed into a path that is in pythons sys.path. can you figure out where it is?

saikat0511 commented 2 years ago

@mattzab pacman -Scc doesn't clear yay AUR package cache (there's yay -Scc for that, and you don't need to clear package cache in the first place) and I have seen reports of --rebuildtree flag not working properly in some cases. Can you try yay -Syu key-mapper-git --answerclean All if that fixes the issue?

mattzab commented 2 years ago

@saikat0511 Wow, thank you for that clarification! I learned something good.

After answerclean All I'm still getting the same error.

@sezanzeb /usr/bin/ contains key-mapper-gtk key-mapper-control key-mapper-helper key-mapper-service

sezanzeb commented 2 years ago

@mattzab

python3
import sys
sys.path

and

find /usr/lib -name keymapper

TheTRCG commented 2 years ago

@sezanzeb Sorry for the late reply I used the find /usr/lib -name keymapper on my system and got

/usr/lib/python3.10/dist-packages/keymapper
/usr/lib/python3/dist-packages/keymapper

In python3 only the pycache files are present but all the files seem to be present in 3.10

When running the key-mapper-gtk command I get the error

Traceback (most recent call last):
  File "/usr/bin/key-mapper-gtk", line 29, in <module>
    from keymapper.data import get_data_path
ModuleNotFoundError: No module named 'keymapper.data'
sezanzeb commented 2 years ago

@TheTRCG

neither /usr/lib/python3.10 nor /usr/lib/python3 are in your sys.path (['', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/usr/local/lib/python3.8/dist-packages', '/usr/lib/python3/dist-packages']). In the output posted at https://github.com/sezanzeb/key-mapper/issues/231#issuecomment-992518148, it shows that it attempts to install it to /usr/lib/python3.8. I don't know why key-mapper got installed to the unused python3.10 directory on your system

If all of this is still the case, I guess the clean reinstallation didn't work yet. Try

sudo pip3 uninstall key-mapper
sudo apt purge key-mapper
sudo apt-get clean
sudo rm /usr/lib/python3.10/dist-packages/keymapper -r
sudo rm /usr/lib/python3/dist-packages/keymapper -r

# afterwards, as shown in the readme
git clone https://github.com/sezanzeb/key-mapper.git
cd key-mapper && ./scripts/build.sh
sudo apt install ./dist/key-mapper-1.2.2.deb
TheTRCG commented 2 years ago

@sezanzeb Holy hot dang, that worked Thank you so much mate, I guess I hadn't removed it properly before

mattzab commented 2 years ago

@sezanzeb

python3
Python 3.10.1 (main, Dec 11 2021, 17:22:55) [GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
import sys
sys.path
['', '/usr/lib/python310.zip', '/usr/lib/python3.10', '/usr/lib/python3.10/lib-dynload', '/home/matt/.local/lib/python3.10/site-packages', '/usr/lib/python3.10/site-packages']

Then,

find /usr/lib -name keymapper
/usr/lib/python3.10/site-packages/keymapper

So, it looks to be in the path. What am I missing?

sezanzeb commented 2 years ago

@mattzab

Lets check if all submodules are there:

find /usr/lib/python3.10/site-packages/keymapper

what does

python3
import keymapper

yield? Is it just failing to import keymapper.data while keymapper can be imported?

Are you using conda or pipenvs?