midi-ld / List.MID

A MIDI-based benchmark for RDF lists
Other
2 stars 0 forks source link

unknown 'midi' module for midi2rdf.py #9

Open hartig opened 1 year ago

hartig commented 1 year ago

I don't manage to get the midi2rdf.py program to run. I tried on two different Linux machines and run into the same issue. I should say that I am a total noob regarding Python. Anyways, here is what I tried and how it fails:

I cloned the repo, entered the src/ directory in it, and issued the following command.

python3 midi2rdf.py

Which gave me the following error message.

  File "midi2rdf.py", line 154
    lyrics_label += text_value
                             ^
TabError: inconsistent use of tabs and spaces in indentation

I opened the file, went to the line indicated in the error message (line 154), and saw that the indentation of this line contains a few tabs, whereas all other lines contain spaces only. Given the error message, I assumed that this bug can be fixed by simply changing the indentation style of line 154 to use spaces only. This worked :-)

... at least to the extend that the error message does not show up anymore. However, now I got another one:

Traceback (most recent call last):
  File "midi2rdf.py", line 3, in <module>
    import midi
ModuleNotFoundError: No module named 'midi'

I did a quick search for the last line of this error message and found a suggestion that I need to do:

pip3 install midi

Yet, this one gives me another error:

ERROR: Could not find a version that satisfies the requirement midi (from versions: none)
ERROR: No matching distribution found for midi

Now I am stuck. Do you have any suggestion for how I may try to proceed to get your program to run?

Maybe of interest, the versions of Python and pip with which I have tried: On one of the two computers on which I tried, I have the following.

# python3 --version
Python 3.8.10
# pip3 --version
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)

On the other computer:

# python3 --version
Python 3.10.12
# pip3 --version
pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)
hartig commented 1 year ago

@albertmeronyo I made a bit more progress on this issue. Namely, I found that the 'midi' module that was missing seems to be called "python-midi". So, I tried

pip3 install python-midi

But that gave me an error message (see below for details). Therefore, I went to the Github repo https://github.com/vishnubob/python-midi/, cloned it locally, and installed the module as described in that repo (i.e., by doing python setup.py install). That worked and now I am finally able to start your midi2rdf.py program. However, the next problem now is that I get a weird error about unicode decoding. That is, if I run

python3 midi2rdf.py --format turtle --order list ../midi/1k.mid out.ttl

I get the following error message.

Traceback (most recent call last):
  File "/home/olaf/Experiments/List.MID/src/midi2rdf.py", line 234, in <module>
    dump = midi2rdf(args.filename[0], args.format, args.order)
  File "/home/olaf/Experiments/List.MID/src/midi2rdf.py", line 27, in midi2rdf
    pattern_midi = midi.read_midifile(filename)
  File "/usr/local/lib/python3.10/dist-packages/midi-0.2.3-py3.10.egg/midi/fileio.py", line 162, in read_midifile
  File "/usr/local/lib/python3.10/dist-packages/midi-0.2.3-py3.10.egg/midi/fileio.py", line 11, in read
  File "/usr/local/lib/python3.10/dist-packages/midi-0.2.3-py3.10.egg/midi/fileio.py", line 18, in parse_file_header
  File "/usr/lib/python3.10/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd3 in position 21: invalid continuation byte

Do you have any suggestions what I can do to get rid oft his error?

Am I actually using the right 'midi' module?


Here is the aforementioned error message that I got when I tried to install 'python-midi' with pip:

Defaulting to user installation because normal site-packages is not writeable
Collecting python-midi
  Using cached python-midi-v0.2.4.tar.gz (6.1 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [7 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-lcbfl9ap/python-midi_3a68028c478648b9ae18eee2bf6da938/setup.py", line 42
          print "No sequencer available for '%s' platform." % platform
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
lalisalala commented 2 weeks ago

Hi @hartig , the issue is rooted in two deprecated Python packages namely: python-midi and keepalive. We have updated the code in the branch "updated" for Python 3.12. In detail, we switch python-midi with mido and keepalive with request. I hope this solves your problem. Please let me know if you encounter any more issues.

hartig commented 2 weeks ago

Thanks @lalisalala ! I will take a look as soon as I find a bit of time ...