【问题标题】:py2exe error : KeyError: 'matplotlib.externals.six.moves' caused by skimagepy2exe 错误:KeyError: 'matplotlib.externals.six.moves' 由 skimage 引起
【发布时间】:2016-04-12 12:56:52
【问题描述】:

我遇到了 skimage(或 scikit-image)和 py2exe 的问题。

我在 Windows 10 中使用 WinPython-64bit-3.4.4.1。

所以这是我的代码:(我让它尽可能简单)

test.py

from skimage import data, filters
print("hello")

我在 CMD 中输入这一行:

py -m py2exe.build_exe test.py

(我试着做了一个 setup.py,但它什么也没改变)

错误是:

Traceback (most recent call last):
  File "C:\WinPython-64bit-3.4.4.1\python-3.4.4.amd64\lib\runpy.py", line 170, in _run_module_as_main
"__main__", mod_spec)
  File "C:\WinPython-64bit-3.4.4.1\python-3.4.4.amd64\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)

... 130 多个类似的行...

  File "C:\WinPython-64bit-3.4.4.1\python-3.4.4.amd64\lib\site-packages\py2exe\mf3.py", line 281, in _find_and_load
self._gcd_import(parent)
  File "C:\WinPython-64bit-3.4.4.1\python-3.4.4.amd64\lib\site-packages\py2exe\mf3.py", line 267, in _gcd_import
return self._find_and_load(name)
  File "C:\WinPython-64bit-3.4.4.1\python-3.4.4.amd64\lib\site-packages\py2exe\mf3.py", line 286, in _find_and_load
  parent_module = self.modules[parent]
KeyError: 'matplotlib.externals.six.moves'

在此错误之前,我收到 valueError: win32com.gen_py.loader is None,但我在某处读到我只需要添加此目录: [python目录]\Lib\site-packages\win32com\gen_py 但是自从我添加了这个目录之后,这个错误就没有了。

但是,我不知道如何解决当前的错误... 我找了一个有类似问题的人,但是他的解决方案是在虚拟机中执行py2exe...

你能帮帮我吗?

【问题讨论】:

    标签: python windows py2exe scikit-image


    【解决方案1】:

    不确定它会改变什么,但您可以尝试:

    • 启动“WinPython 命令提示符.exe”

    • 键入“python -m py2exe.build_exe test.py”

    【讨论】:

    • 最后还是放弃了py2exe,用pyInstaller试试。它给了我更好的错误,并且事情在他们的网站上有很好的记录......所以,它是模块 skimage.io 导致问题:导入似乎很奇怪......看到这个:stackoverflow.com/questions/34761862/…
    猜你喜欢
    • 2021-12-17
    • 1970-01-01
    • 2021-02-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-13
    • 2021-09-19
    相关资源
    最近更新 更多