Python 3.6 ModuleNotFoundError: No module named '_sysconfigdata_m_darwin_darwin'

Issue #185 resolved
Ryan Jarvis created an issue

I have a very minimal app:

if __name__ == '__main__':

    from PyObjCTools import AppHelper

    AppHelper.runEventLoop()

and a setup.py of:

from setuptools import setup

plist = dict(
    CFBundleDocumentTypes=[
        dict(
            CFBundleTypeExtensions=["Bender", "*"],
            CFBundleTypeName="Bender File",
            CFBundleTypeRole="Editor",
            NSDocumentClass="BenderDocument",
        ),
    ],
)

setup(
    name="Bender",
    app=["Bender.py"],
    data_files=["English.lproj"],
    options={'py2app': {'plist': plist}},
    setup_requires=[
        "py2app",
        'pyobjc-core',
        "pyobjc-framework-Cocoa",
    ]
)

There is also a .xib file. This runs fine on 2.7 but running the same file on 3.6 gets me the following traceback:

Traceback (most recent call last):
  File "/Users/work/PycharmProjects/py2appdebug/dist/Bender.app/Contents/Resources/__boot__.py", line 81, in <module>
    _run()
  File "/Users/work/PycharmProjects/py2appdebug/dist/Bender.app/Contents/Resources/__boot__.py", line 66, in _run
    exec(compile(source, path, 'exec'), globals(), globals())
  File "/Users/work/PycharmProjects/py2appdebug/dist/Bender.app/Contents/Resources/Bender.py", line 13, in <module>
    from PyObjCTools import AppHelper
  File "PyObjCTools/AppHelper.pyc", line 14, in <module>
  File "AppKit/__init__.pyc", line 8, in <module>
  File "objc/__init__.pyc", line 32, in <module>
  File "objc/_bridgesupport.pyc", line 13, in <module>
  File "pkg_resources/__init__.pyc", line 1026, in <module>
  File "pkg_resources/__init__.pyc", line 1029, in Environment
  File "pkg_resources/__init__.pyc", line 267, in get_supported_platform
  File "pkg_resources/__init__.pyc", line 473, in get_build_platform
  File "sysconfig.pyc", line 689, in get_platform
  File "sysconfig.pyc", line 550, in get_config_vars
  File "sysconfig.pyc", line 421, in _init_posix
ModuleNotFoundError: No module named '_sysconfigdata_m_darwin_darwin'

Installed packages:

altgraph==0.13
beautifulsoup4==4.5.3
bs4==0.0.1
cffi==1.9.1
cryptography==1.7.2
idna==2.2
lxml==3.7.3
macholib==1.8
modulegraph==0.13
paramiko==2.1.1
py2app==0.11
pyasn1==0.2.2
pycparser==2.17
pyobjc-core==3.2.1
pyobjc-framework-Cocoa==3.2.1
pysftp==0.2.9
python-dateutil==2.6.0
requests==2.13.0
six==1.10.0

I am running OS X 10.12.3

This is happening after py2app assembles the app. It appears that PyObjC can't find something in it's path but after typing this all up it may be an issue with py2app instead. Thoughts?

Comments (5)

  1. Ronald Oussoren repo owner

    This is a problem with py2app and recent versions of python: the stdlib module "sysconfig" imports a "sysconfigdata..." module where the "..." is calculated dynamically. That module is therefore not imported using a normal import statement, which is why py2app doesn't detect is.

    I'll try to fix this with a py2app recipe.

  2. Ronald Oussoren repo owner

    I'm working on a proper fix, but for now you can add "import _sysconfigdata_m_darwin_darwin" in the main script of the application, this can be in a function that's never called. That way py2app will recognise the import statement and will add the module to the application bundle.

  3. Log in to comment