vishnubob / python-midi

Python MIDI library
MIT License
1.51k stars 370 forks source link

module object has no 'read_midfile' #144

Open sreekanth3333 opened 6 years ago

sreekanth3333 commented 6 years ago

Traceback (most recent call last): File "rbm_chords.py", line 36, in songs = get_songs('Pop_Music_Midi') # These songs have already been converted from midi to msgpack File "rbm_chords.py", line 32, in get_songs raise e AttributeError: 'module' object has no attribute 'read_midifile'

I am getting the above error, please help

MaurizioB commented 6 years ago

We don't know what get_songs does, can you clarify?

sreekanth3333 commented 6 years ago

import numpy as np import pandas as pd import msgpack import glob import tensorflow as tf from tensorflow.python.ops import control_flow_ops from tqdm import tqdm

###################################################

In order for this code to work, you need to place this file in the same

directory as the midi_manipulation.py file and the Pop_Music_Midi directory

import midi_manipulation

import os

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

def get_songs(path): files = glob.glob('{}/.mid'.format(path)) songs = [] for f in tqdm(files): try: song = np.array(midi_manipulation.midiToNoteStateMatrix(f)) if np.array(song).shape[0] > 50: songs.append(song) except Exception as e: raise e return songs

songs = get_songs('Pop_Music_Midi') # These songs have already been converted from midi to msgpack print("{} songs processed".format(len(songs))) ###################################################

This is the coding. I think read_midifile is missing from the code which I got from web. Is it so?

MaurizioB commented 6 years ago

Are you sure you don't have other python files named "midi.py" within the directory of the script you are running (or in the PYTHONPATH)? I suppose you are using this: https://github.com/llSourcell/Music_Generator_Demo (in these cases, it is preferrable to link to the project or the file within it, to better help people understand its structure, instead of making them search around the web). Also, as a side note, please use the code formatting when writing code in issues and comments, the code you pasted is almost unreadable.

Paras-dua commented 6 years ago

Traceback (most recent call last): File "rbm_chords.py", line 36, in songs = get_songs('Pop_Music_Midi') # These songs have already been converted from midi to msgpack File "rbm_chords.py", line 32, in get_songs raise e File "rbm_chords.py", line 28, in get_songs song = np.array(midi_manipulation.midiToNoteStateMatrix(f)) File "C:\Users\Paras\Downloads\tensorflow-music-generator-master\midi_manipulation.py", line 11, in midiToNoteStateMatrix pattern = midi.read_midifile(midifile) AttributeError: module 'midi' has no attribute 'read_midifile' Running This project: https://github.com/burliEnterprises/tensorflow-music-generator Same error. Any solution yet?

ernestpascual commented 6 years ago

i tried reinstalling all dependencies in both python2 and python3. This one did the trick

pip3 install git+https://github.com/vishnubob/python-midi@feature/python3

shaneleblanc commented 6 years ago

That link is no longer valid, but I was able to get rbm_chords.py working by installing the dependencies via pip2 and specifying #!/usr/bin/python in rbm_chords.py (so python2.7, not 3 per the instructions)

lawakesh23 commented 5 years ago

when run rbm_chords.py files:

ModuleNotFoundError: No module named 'numpy.core._multiarray_umath' ImportError: numpy.core.multiarray failed to import

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "", line 980, in _find_and_load SystemError: <class '_frozen_importlib._ModuleLockManager'> returned a result with an error set ImportError: numpy.core._multiarray_umath failed to import ImportError: numpy.core.umath failed to import 2019-02-24 23:31:20.409551: F tensorflow/python/lib/core/bfloat16.cc:675] Check failed: PyBfloat16_Type.tp_base != nullptr

i face this issue please help me . Running this Project [https://github.com/llSourcell/Music_Generator_Demo]

lawakesh23 commented 5 years ago

Traceback (most recent call last): File "rbm_chords.py", line 36, in songs = get_songs('Pop_Music_Midi') # These songs have already been converted from midi to msgpack File "rbm_chords.py", line 32, in get_songs raise e File "rbm_chords.py", line 28, in get_songs song = np.array(midi_manipulation.midiToNoteStateMatrix(f)) File "E:\project\tensorflow-music-generator-master\midi_manipulation.py", line 11, in midiToNoteStateMatrix pattern = midi.read_midifile(midifile) AttributeError: module 'midi' has no attribute 'read_midifile'

@sreekanth3333 please help me how you get rid from this error. i already run the pip install git+https://github.com/vishnubob/python-midi@feature/python3 but got this error

terrywang15 commented 5 years ago

I am having the same exact issue with the same Music_Generator_Demo project. Was able to follow #124 and install midi 0.2.3 through github but did not resolve the issue. Running python 3.6.