ImportError: No Module named 'mt_exceptions

2019-05-12 01:10发布

问题:

Forgive my ignorance in advance, I am very new to python. I am trying to use a python 3 version (https://code.google.com/r/artdent-mingus-python3/) of the Mingus library (https://pypi.python.org/pypi/mingus/) in 3.4.2. When trying to use the note module, I keep getting the ImportError listed in the title.

Based on my research on similar ImportError questions, I have tried the following things: -I made sure there was a mt_exceptions.py file in the relevant directory -I made sure each mingus directory in the site-packages directory has init.py file -I deleted the .pyc files in the mingus directory

Any pointers on what I might try next?

回答1:

I've solved the problem by manually entering in "C:\Python34\Lib\site-packages\mingus\core" and editing the file (In my case, I had to edit notes.py from "from mt_exceptions import NoteFormatError, RangeError, FormatError" to "from mingus.core.mt_exceptions import NoteFormatError, RangeError, FormatError", and then I got a typical Python 2.x running on 3.x dict error. So that's the problem!

Solution: Use Python 2.x, or update the whole schmere to 3.x (That's what I'm doing).

As you can see here, Python 3.x has changed the import syntax a bit, and that's exactly what's happening. I had to run 2to3 through all the mingus source code and fix the imports manually from all files (Basically, porting the whole thing to Python 3.x).