Sf2utils ModuleNotFound even if installed

Description:

Dear all,
I’m new to SCAMP and to this forum, but I already see me using this tool extensively and I’m glad someone put in so much effort to build and keep on scaling it.

Premise: I work on Windows 11, SCAMP Version: 0.9.2.post3

Newby problem: even if I do have sf2utils installed, my code throws errors whenever I try to pass in instrument name arguments to new_part(). Instead, leaving the arguments empty make it work normally both in score xml output and in playback, with the default piano sound.
Errors also happen when I try to Session().print_default_soundfont_presets(), as in the example I’m reporting here.
Apparently there is something going on with soundfont configurations in my computer, but I’m really not able to tackle the issue.

Error printout:

WARNING:root:sf2utils was not found; info about soundfont presets will not be available.
PRESETS FOR default (general_midi)
Traceback (most recent call last):
  File "C:\Users\giuli\Coding\scampExp\app.py", line 10, in <module>
    S.print_default_soundfont_presets()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "C:\Users\giuli\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\scamp\instruments.py", line 288, in print_default_soundfont_presets
    print_soundfont_presets(self.default_soundfont)
    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\giuli\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\scamp\_soundfont_host.py", line 379, in print_soundfont_presets
    for preset in get_soundfont_presets(which_soundfont):
                  ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "C:\Users\giuli\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\scamp\_soundfont_host.py", line 368, in get_soundfont_presets
    raise ModuleNotFoundError("Cannot inspect soundfont presets; please install sf2utils.")
ModuleNotFoundError: Cannot inspect soundfont presets; please install sf2utils.
PS C:\Users\giuli\Coding\scampExp> 

The full code that resulted in the error:

from scamp import *

S = Session()

S.print_default_soundfont_presets()

piano = S.new_part()

S.start_transcribing(piano)

piano.play_note(60, 0.1, 2)

Hey!

So this is definitely and issue with managing python interpreters, because it’s saying you don’t have sf2utils installed. If you did install it, it means you installed it to a different interpreter than the one you’re using to run the code.

You might try running which python in the terminal to figure out where the python interpreter you’re using is?

Dear Marc, thank you for helping me.
I tried to run which python, but the console doesn’t recognise it as a command. So I’ve done some little more investigation: sf2utils is installed in the python313 scrpits folder, and when I also specify to run my code with the python3.13 command on the terminal, it still warns that sf2utils was not found.
That is weird especially because, just out of curiosity, when I’ve tried to import sf2utils in the code as a module it does import it normally.
At this point, I’m pretty afraid there might be something deeper broken in either my python or my pc setup, but that might be scary to me because I am really not a computer expert and I’m afraid to break things even more :cold_face:

Have you tried doing all of this in Thonny, the simple IDE that I suggest in the documentation? Part of the reason I suggest this is that it’s sort of self-contained, and if you install the packages through Thonny, there doesn’t tend to be this confusion about which python you’re installing them to.