【问题标题】:ImportError: No Module named 'mt_exceptions' when using Mingus libraryImportError:使用 Mingus 库时没有名为“mt_exceptions”的模块
【发布时间】:2014-11-18 00:47:41
【问题描述】:

请原谅我的无知,我对python很陌生。我正在尝试在 3.4.2 中使用 Mingus 库 (https://pypi.python.org/pypi/mingus/) 的 python 3 版本 (https://code.google.com/r/artdent-mingus-python3/)。尝试使用 note 模块时,我不断收到标题中列出的 ImportError。

根据我对类似 ImportError 问题的研究,我尝试了以下方法: -我确保相关目录中有一个 mt_exceptions.py 文件 -我确保 site-packages 目录中的每个 mingus 目录都有 init.py 文件 -我删除了mingus目录下的.pyc文件

关于我下一步可能尝试什么的任何指示?

【问题讨论】:

  • 检查软件包的安装位置并确保安装位置在 sys.path 或 PYTHONPATH 中
  • 当我尝试时: >>> import sys >>> print(sys.path) 输出包括: ['C:\\Python34\\lib\\site-packages']软件包已安装。
  • 您能否发布目录树内容并显示 mt_exception 所在的位置。
  • 'Python34 | +--库 | | +--站点包 | | +--明格斯 | | +--核心 | | +--mt_exceptions.py | '
  • 你也试过 import mingus.core.mt_exceptions

标签: python python-3.x importerror


【解决方案1】:

我已经通过手动输入“C:\Python34\Lib\site-packages\mingus\core”并编辑文件解决了这个问题(在我的例子中,我必须从 编辑 notes.py” from mt_exceptions import NoteFormatError, RangeError, FormatError" to " from mingus.core.mt_exceptions import NoteFormatError, RangeError, FormatError",然后我得到了一个典型的Python 2.x 在3 上运行。 x dict 错误。这就是问题所在!

解决方案:使用 Python 2.x,or update the whole schmere to 3.x(我正在这样做)。

As you can see here,Python 3.x 稍微改变了导入语法,正是正在发生的事情。我必须通过所有 mingus 源代码运行 2to3 并手动修复所有文件的导入(基本上,将整个东西移植到 Python 3.x)。

【讨论】:

  • 请问什么是'schmere'?
【解决方案2】:

埃里克森威廉斯是正确的。我用 2to3.py 修复了这个问题。我安装了 Mingus:

pip install mingus

然后,我导航到 pip 安装 Mingus 的目录:

pip show mingus

在 Mingus 的顶级目录中 (~/AppData/Local/Programs/Python/Python37-32/Lib/site-packages/mingus)

我跑了:

~/AppData/Local/Programs/Python/Python37-32/Tools/scripts/2to3.py -w .

到目前为止,这已经为我修复了 Mingus。

【讨论】:

    猜你喜欢
    • 2020-12-21
    • 2016-03-09
    • 2015-08-04
    • 2017-01-28
    • 1970-01-01
    • 1970-01-01
    • 2016-06-01
    • 2013-03-11
    相关资源
    最近更新 更多