简体   繁体   English

py2app - 未找到模块(有条件导入)

[英]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.我目前正在使用 Tkinter 进行个人项目,我想将所有内容都打包到 macOS 应用程序中。

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

The message about modules that weren't found is a warning, not an error.有关未找到模块的消息是警告,而不是错误。 These may or may not be problem, but often aren't.这些可能是也可能不是问题,但通常不是。 In particular the missing optional modules that are used from the various "compat" modules are almost certainly harmless if you use Python 3 (because those are imports of names in the Python 2 stdlib).特别是,如果您使用 Python 3,那么从各种“compat”模块中使用的缺失的可选模块几乎肯定是无害的(因为这些是 Python 2 stdlib 中名称的导入)。

At first glance the missing "sympy", "regex" and "yaml" could be problematic, you could try installing these python packages.乍一看,缺少的“sympy”、“regex”和“yaml”可能有问题,您可以尝试安装这些python包。

As a bit of background, PyObjC shows 3 lists of missing modules at the end of a build (assuming there are missing modules in the category):作为背景知识,PyObjC 在构建结束时显示了 3 个缺失模块的列表(假设类别中存在缺失模块):

  1. Unconditional imports: These are imports that are always executed when a module is imported (toplevel imports and imports in class scope)无条件导入:这些是在导入模块时始终执行的导入(顶级导入和类范围内的导入)

    These tend to be problematic, unless the module containing the import is itself optional.这些往往是有问题的,除非包含导入的模块本身是可选的。

  2. Conditional imports: These are imports that are conditional, either because they are done in a function or because they are in some sort of conditional statement.条件导入:这些是有条件的导入,要么是因为它们是在函数中完成的,要么是因为它们在某种条件语句中。

    These tend to be harmless.这些往往是无害的。

  3. Missing names in a "from FOO import NAME" statement: In these statements the "NAME" can refer to modules or to definitions in the imported module. “from FOO import NAME”语句中缺少名称:在这些语句中,“NAME”可以指代模块或导入模块中的定义。 Py2app reports these when it is not 100% clear that NAME refers to a module. Py2app 在 NAME 指代模块不是 100% 明确时报告这些。

    These tend to be harmless, especially when the module ("FOO") is a C extension.这些往往是无害的,尤其是当模块(“FOO”)是 C 扩展时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM