问题
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).
回答2:
Ericson Willians is correct. I fixed this with 2to3.py. I installed Mingus with:
pip install mingus
Then, I navigated to the directory where pip installed Mingus:
pip show mingus
In the top directory for Mingus (~/AppData/Local/Programs/Python/Python37-32/Lib/site-packages/mingus)
I ran:
~/AppData/Local/Programs/Python/Python37-32/Tools/scripts/2to3.py -w .
This has fixed Mingus for me, so far.
来源:https://stackoverflow.com/questions/26984731/importerror-no-module-named-mt-exceptions-when-using-mingus-library