pythontkinterpy2app

py2app - Modules not found (conditional imports)


I'm currently working on a personal project with Tkinter and I want to wrap everything into a macOS app.

Unfortunately, the command to create a production build not working and I always have an error related to "Modules not found"

Modules not found (conditional imports):
 * ConfigParser (dogpile.util.compat)
 * Cookie (requests.compat)
 * OpenSSL.crypto (urllib3.contrib.pyopenssl)
 * Queue (urllib3.util.queue)
 * StringIO (dogpile.util.compat, pkg_resources._vendor.six, requests.compat, six, urllib3.packages.six)
 * backports.functools_lru_cache (soupsieve.util)
 * cPickle (dogpile.util.compat)
 * colors (tkmacosx.variables)
 * com (pkg_resources._vendor.appdirs)
 * com.sun.jna (pkg_resources._vendor.appdirs)
 * com.sun.jna.platform (pkg_resources._vendor.appdirs)
 * cookielib (requests.compat)
 * copy_reg (soupsieve.util)
 * cryptography.x509.extensions (urllib3.contrib.pyopenssl)
 * regex (rebulk.remodule)
 * sympy (subliminal.score)
 * thread (dogpile.util.compat)
 * urllib2 (requests.compat)
 * urlparse (requests.compat)
 * win32com (pkg_resources._vendor.appdirs)
 * win32com.shell (pkg_resources._vendor.appdirs)
 * yaml (guessit.options)

I've tried many workaround but nothing works..

The modules I use :

tkinter
subliminal
tkmacosx

Solution

  • Always check the version of pip and python you are using! I had an similar issue where tkmacosxcould not be imported. Turned out I was using pip@3.10 but python@3.11 So using:

    pip3.11 install tkmacosx

    solved it for me