python – Cx_Freeze找不到pkg_resources /*.*’

我正在尝试使用cx_Freeze setup.py文件使用以下命令构建EXE:

python setup.py bdist_msi

命令的输出结束于:

Copying data from package pkg_resources… error: [Error 3] The system
cannot find the path specified: ‘C:\Program
Files\Anaconda2\lib\site-packages\setuptools-27.2.0-py2.7.egg\pkg_resources/*.*’

我不知道该怎么做.我已经检查过了setuptools的蛋,并且里面有一个pgk_resources库,我不知道该怎么做.

我正在使用conda安装和python2.7.

任何帮助将不胜感激.

最佳答案 那是因为cx_Freeze无法使用已打包为.eggs的软件包的子包.正常的Python安装使用pip,它总是解压缩.eggs,与Anaconda不同.

相应的问题:Failed to find module in subpackage in zipped egg · Issue #120 · anthony-tuininga/cx_Freeze.它通过修复程序链接到pull request

diff --git a/cx_Freeze/finder.py b/cx_Freeze/finder.py
--- a/cx_Freeze/finder.py
+++ b/cx_Freeze/finder.py
@@ -61,6 +61,15 @@
         If the module is found, this returns information in the same format
         as :func:`imp.find_module`. Otherwise, it returns None.
         """
+        # FIX: retrieve_loadable_module dict uses paths with OS's separator
+        # as keys. However the path received as argument can have mixed
+        # slashes. This may cause some searches to fail when they should
+        # work. One case where this seems critical is when there are
+        # subpackages inside an egg package.
+        #
+        # See `record_loadable_module` method to see how mixed slashes
+        # happen.
+        path = os.path.normpath(path)
         try:
             return self.retrieve_loadable_module(path, modulename)
         except KeyError:

使用pip install替换所有.eggs的所有.eggs – 如另一个答案所建议的那样升级 – 只是一个临时解决方案 – 直到你得到另一个.egg.

点赞