ModuleNotFoundError: No module named '_sysconfigdata_m_darwin_darwin'

ModuleNotFoundError: No module named '_sysconfigdata_m_darwin_darwin'

我正在 Python 为我的团队开发一个 Rally 报告工具,我正在尝试使用 cx-freeze 打包它。我遇到了 ModuleNotFound 错误,我想知道这是否是因为 cx-freeze 不支持 pygal(真的希望不是这种情况,因为我必须重写很多东西)

celinaperalta$ /Users/celinaperalta/Documents/NYLTesting/rally-exports/build/exe.macosx-10.9-x86_64-3.7/RallyGUI ; exit;
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cx_Freeze/initscripts/__startup__.py", line 40, in run
    module.run()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cx_Freeze/initscripts/Console.py", line 37, in run
    exec(code, {'__name__': '__main__'})
  File "RallyGUI.py", line 8, in <module>
  File "/Users/celinaperalta/Documents/NYLTesting/rally-exports/build/exe.macosx-10.9-x86_64-3.7/RallyReportTool.py", line 7, in <module>
    import pygal
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pygal/__init__.py", line 28, in <module>
    import pkg_resources
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/__init__.py", line 959, in <module>
    class Environment:
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/__init__.py", line 963, in Environment
    self, search_path=None, platform=get_supported_platform(),
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/__init__.py", line 190, in get_supported_platform
    plat = get_build_platform()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/__init__.py", line 395, in get_build_platform
    plat = get_platform()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/sysconfig.py", line 675, in get_platform
    get_config_vars(),
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/sysconfig.py", line 551, in get_config_vars
    _init_posix(_CONFIG_VARS)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/sysconfig.py", line 422, in _init_posix
    _temp = __import__(name, globals(), locals(), ['build_time_vars'], 0)
ModuleNotFoundError: No module named '_sysconfigdata_m_darwin_darwin'

cx_freeze 不会自动包含所有包。当您发现 ModuleNotFoundError 时,您需要在您的设置中明确包含该模块,例如 -

build_exe_options = {'packages': ['_sysconfigdata_m_darwin_darwin']}