Duckapple / Kat

Kattis shell for getting examples, testing and submitting.
18 stars 6 forks source link

Problem with using the `--sound` argument on MacOS #75

Open adamlass opened 3 years ago

adamlass commented 3 years ago

Problem with using the --sound argument on MacOS:

%0A%0A%60%60%60%0ATraceback %28most recent call last%29%3A%0A File %22%2Fusr%2Flocal%2Fbin%2Fkattis%22%2C line 40%2C in main%0A execCommand%5Bcommand%5D%28data%29%0A File %22%2FUsers%2Fadamlass%2FDocuments%2Fcs1%2FKat%2Fcommands%2Fsubmit.py%22%2C line 79%2C in submitCommand%0A winsound%28%29%0A File %22%2FUsers%2Fadamlass%2FDocuments%2Fcs1%2FKat%2Fhelpers%2Fsound.py%22%2C line 8%2C in winsound%0A playsound%28random.choice%28glob.glob%28prefix %2B %22%2Fwin%2F%2A.mp3%22%29%29%29%0A File %22%2FLibrary%2FFrameworks%2FPython.framework%2FVersions%2F3.9%2Flib%2Fpython3.9%2Fsite-packages%2Fplaysound.py%22%2C line 55%2C in _playsoundOSX%0A from AppKit import NSSound%0AModuleNotFoundError%3A No module named %27AppKit%27%0A%0A%60%60%60

adamlass commented 3 years ago

A more readable format:

Traceback (most recent call last):
   File "/usr/local/bin/kattis", line 40, in main
    execCommand[command](data)
   File "/Users/adamlass/Documents/cs1/Kat/commands/submit.py", line 79, in submitCommand
    winsound()
   File "/Users/adamlass/Documents/cs1/Kat/helpers/sound.py", line 8, in winsound
    playsound(random.choice(glob.glob(prefix + "/win/*.mp3")))
   File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/playsound.py", line 55, in _playsoundOSX
    from AppKit     import NSSound
 ModuleNotFoundError: No module named 'AppKit'

Error occurred:
 No module named 'AppKit'
Duckapple commented 3 years ago

Apparently the playsound package has an extra dependency on MacOS, details in this StackOverflow answer.

It seems like you have to install a bridge between Python and Objective C called PyObjC via pip