Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] ModuleNotFoundError: No module named 'preferredsoundplayer' #19

Closed
bttger opened this issue Jul 18, 2022 · 13 comments
Closed

[BUG] ModuleNotFoundError: No module named 'preferredsoundplayer' #19

bttger opened this issue Jul 18, 2022 · 13 comments
Labels
bug Something isn't working

Comments

@bttger
Copy link

bttger commented Jul 18, 2022

Describe the bug 馃悰
I've installed termtpye via the AUR. I had to choose between the repository or the AUR package for python-playsound and chose the repository version. When starting termtype I get the following error:

Traceback (most recent call last):
  File "/usr/bin/termtyper", line 5, in <module>
    from termtyper.__init__ import main
  File "/usr/lib/python3.10/site-packages/termtyper/__init__.py", line 1, in <module>
    from .ui import TermTyper
  File "/usr/lib/python3.10/site-packages/termtyper/ui/__init__.py", line 1, in <module>
    from .tui import TermTyper
  File "/usr/lib/python3.10/site-packages/termtyper/ui/tui.py", line 12, in <module>
    from termtyper.ui.settings_options import MenuSlide
  File "/usr/lib/python3.10/site-packages/termtyper/ui/settings_options.py", line 11, in <module>
    from termtyper.ui.widgets import banners
  File "/usr/lib/python3.10/site-packages/termtyper/ui/widgets/__init__.py", line 2, in <module>
    from .race_hud import RaceHUD
  File "/usr/lib/python3.10/site-packages/termtyper/ui/widgets/race_hud.py", line 10, in <module>
    from ...utils import Parser
  File "/usr/lib/python3.10/site-packages/termtyper/utils/__init__.py", line 3, in <module>
    from .play_keysound import play_keysound, play_failed
  File "/usr/lib/python3.10/site-packages/termtyper/utils/play_keysound.py", line 2, in <module>
    from preferredsoundplayer import playsound
ModuleNotFoundError: No module named 'preferredsoundplayer'

To Reproduce 馃悾
See bug description.

Expected behavior 馃
It should work after installing the package.

Screenshots 馃
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information): 馃

  • OS: Manjaro

Additional context 馃摑
Add any other context about the problem here.

@bttger bttger added the bug Something isn't working label Jul 18, 2022
@kraanzu
Copy link
Owner

kraanzu commented Jul 18, 2022

Yeah about that, preferred-sound-player is not in the AUR.
So I am not so sure how to approach this.
Ig I'll add a pip command in pkgbuild, tho I don't prefer this :(

In the meantime you can install it by this command:

pip install preferredsoundplayer

@drjaska
Copy link

drjaska commented Jul 19, 2022

Why is this a mandatory module which leads to a crash when missing instead of being optional with a note when booting?

Based on the name this module looks like bloat for those who don't care about having sound be played by python.

@bttger
Copy link
Author

bttger commented Jul 19, 2022

Based on the name this module looks like bloat for those who don't care about having sound be played by python.

I agree. I don't need sound.

@kraanzu
Copy link
Owner

kraanzu commented Jul 19, 2022

Based on the name this module looks like bloat for those who don't care about having sound be played by python.

I was using playsound but somehow it's not working on linux anymore... So the alternative..... which seemed to work just fine

I agree. I don't need sound.

Hmm, ig I'll add a parameter such as -q or -quiet which will run termtyper in quiet mode?

@drjaska
Copy link

drjaska commented Jul 19, 2022

Requiring a parameter to not crash doesn't feel good to me. Consider automatically detecting the lack of sound modules and entering mute mode on top of having opt-in or opt-out for sound.

@kraanzu
Copy link
Owner

kraanzu commented Jul 19, 2022

Requiring a parameter to not crash doesn't feel good to me

No I am not suggesting this as an alternative to crashing. Crashing was due to the reason that the sound module was not packaged for the AUR.

Consider automatically detecting the lack of sound modules and entering mute mode on top of having opt-in or opt-out for sound.

I don't see how this is feasible. The sound gets installed along with termtyper.
If it throws an error internally, I can use try-catch statements to just ignore the error.

As far as I know, python does not have method for 'optional' installation (something like rust does)

@drjaska
Copy link

drjaska commented Jul 19, 2022

Crashing was due to the reason that the sound module was not packaged for the AUR.

I got this same crash with git clone, cd, install, cd ~, termtyper on Ubuntu 22.04. It's not AUR specific.

@kraanzu
Copy link
Owner

kraanzu commented Jul 19, 2022

I see. Can you add any pictures?

@drjaska
Copy link

drjaska commented Jul 19, 2022

I initially fixed this with the suggested pip install preferredsoundplayer, I've lost my shell log due to having rebooted after running it but if I now run these I get the following.

鈹屸攢[drjaska@perkele] - [~] - [2022-07-19 08:50:36]
鈹斺攢[0] <> pip uninstall preferredsoundplayer
Found existing installation: preferredsoundplayer 0.0.5
Uninstalling preferredsoundplayer-0.0.5:
  Would remove:
    /home/drjaska/.local/lib/python3.10/site-packages/preferredsoundplayer-0.0.5.dist-info/*
    /home/drjaska/.local/lib/python3.10/site-packages/preferredsoundplayer/*
Proceed (Y/n)? 
  Successfully uninstalled preferredsoundplayer-0.0.5
鈹屸攢[drjaska@perkele] - [~] - [2022-07-19 08:50:59]
鈹斺攢[0] <> termtyper
Traceback (most recent call last):
  File "/home/drjaska/.local/bin/termtyper", line 5, in <module>
    from termtyper.__init__ import main
  File "/home/drjaska/.local/lib/python3.10/site-packages/termtyper/__init__.py", line 1, in <module>
    from .ui import TermTyper
  File "/home/drjaska/.local/lib/python3.10/site-packages/termtyper/ui/__init__.py", line 1, in <module>
    from .tui import TermTyper
  File "/home/drjaska/.local/lib/python3.10/site-packages/termtyper/ui/tui.py", line 12, in <module>
    from termtyper.ui.settings_options import MenuSlide
  File "/home/drjaska/.local/lib/python3.10/site-packages/termtyper/ui/settings_options.py", line 11, in <module>
    from termtyper.ui.widgets import banners
  File "/home/drjaska/.local/lib/python3.10/site-packages/termtyper/ui/widgets/__init__.py", line 2, in <module>
    from .race_hud import RaceHUD
  File "/home/drjaska/.local/lib/python3.10/site-packages/termtyper/ui/widgets/race_hud.py", line 10, in <module>
    from ...utils import Parser
  File "/home/drjaska/.local/lib/python3.10/site-packages/termtyper/utils/__init__.py", line 3, in <module>
    from .play_keysound import play_keysound, play_failed
  File "/home/drjaska/.local/lib/python3.10/site-packages/termtyper/utils/play_keysound.py", line 2, in <module>
    from preferredsoundplayer import playsound
ModuleNotFoundError: No module named 'preferredsoundplayer'
鈹屸攢[drjaska@perkele] - [~] - [2022-07-19 08:51:12]
鈹斺攢[1] <> 

I can at a later date say if things differ after a clean system install as I'm going to reformat my drive.

@bttger
Copy link
Author

bttger commented Jul 19, 2022

I initially fixed this with the suggested pip install preferredsoundplayer, I've lost my shell log due to having rebooted after running it but if I now run these I get the following.

鈹屸攢[drjaska@perkele] - [~] - [2022-07-19 08:50:36]
鈹斺攢[0] <> pip uninstall preferredsoundplayer
Found existing installation: preferredsoundplayer 0.0.5
Uninstalling preferredsoundplayer-0.0.5:
  Would remove:
    /home/drjaska/.local/lib/python3.10/site-packages/preferredsoundplayer-0.0.5.dist-info/*
    /home/drjaska/.local/lib/python3.10/site-packages/preferredsoundplayer/*
Proceed (Y/n)? 
  Successfully uninstalled preferredsoundplayer-0.0.5
鈹屸攢[drjaska@perkele] - [~] - [2022-07-19 08:50:59]
鈹斺攢[0] <> termtyper
Traceback (most recent call last):
  File "/home/drjaska/.local/bin/termtyper", line 5, in <module>
    from termtyper.__init__ import main
  File "/home/drjaska/.local/lib/python3.10/site-packages/termtyper/__init__.py", line 1, in <module>
    from .ui import TermTyper
  File "/home/drjaska/.local/lib/python3.10/site-packages/termtyper/ui/__init__.py", line 1, in <module>
    from .tui import TermTyper
  File "/home/drjaska/.local/lib/python3.10/site-packages/termtyper/ui/tui.py", line 12, in <module>
    from termtyper.ui.settings_options import MenuSlide
  File "/home/drjaska/.local/lib/python3.10/site-packages/termtyper/ui/settings_options.py", line 11, in <module>
    from termtyper.ui.widgets import banners
  File "/home/drjaska/.local/lib/python3.10/site-packages/termtyper/ui/widgets/__init__.py", line 2, in <module>
    from .race_hud import RaceHUD
  File "/home/drjaska/.local/lib/python3.10/site-packages/termtyper/ui/widgets/race_hud.py", line 10, in <module>
    from ...utils import Parser
  File "/home/drjaska/.local/lib/python3.10/site-packages/termtyper/utils/__init__.py", line 3, in <module>
    from .play_keysound import play_keysound, play_failed
  File "/home/drjaska/.local/lib/python3.10/site-packages/termtyper/utils/play_keysound.py", line 2, in <module>
    from preferredsoundplayer import playsound
ModuleNotFoundError: No module named 'preferredsoundplayer'
鈹屸攢[drjaska@perkele] - [~] - [2022-07-19 08:51:12]
鈹斺攢[1] <> 

I can at a later date say if things differ after a clean system install as I'm going to reformat my drive.

This is the same traceback that I got when I opened this issue.

@liric28
Copy link

liric28 commented Jul 20, 2022

Copy the following and replace it -->>> "play_keysound.py"

from threading import Thread
from playsound import playsound
from os import path

from ..utils import Parser

SOUNDS_LOC = path.join(path.dirname(file), "..", "sounds")

def get_sound_location(sound: str) -> str:
return str(path.join(SOUNDS_LOC, f"{sound}.wav"))

def play(sound_file: str) -> None:
Thread(target=playsound, args=(sound_file,), daemon=True).start()

def play_keysound() -> None:
sound = Parser().get_theme("sound")
sound_file = get_sound_location(sound)
playsound(sound_file)

def play_failed() -> None:
sound_file = get_sound_location("failed")
playsound(sound_file)

kraanzu added a commit that referenced this issue Jul 20, 2022
@kraanzu
Copy link
Owner

kraanzu commented Jul 20, 2022

My bad, I just ran the test file without actually installing it with pip..
Sorry for the inconvenience 馃槥

I've pushed the updates

@kraanzu
Copy link
Owner

kraanzu commented Jul 27, 2022

The error has been fixed and a quiet mode flag feature has been added in this commit

@kraanzu kraanzu closed this as completed Jul 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants