Play midi alongside animation my goal is to play exact midi note in a certain frame, so i thought the only way is to use a midi in/out python library, and execute a certain python command line or script in the required keyframe, so from here my question becomes: is there any way to keyframe a python script? 
of course if there are any other easier ways for my goal, it would be better
I don't know if you can do that, but you shouldn't need to. Try simply exporting the MIDI to a sound file, and using the Video Sequence Editor (I think) to align it with your animation.