5

I'm trying to build an EXE using a cx_Freeze setup.py file with the following command:

python setup.py bdist_msi

The command's output ends with:

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/*.*'

I'm not sure what to make of it. I've checked and the setuptools' egg exists, and inside it there is a pgk_resources library, and I'm not sure what to do.

I'm using a conda installation and python2.7.

Any help will be appreciated.

Yiftach
  • 347
  • 1
  • 2
  • 12
  • Hey @Yiftach does the problem still occur? I am facing the same problem. error: [Error 3] The system cannot find the path specified: 'C:\\Anaconda2\\lib\ \site-packages\\setuptools-27.2.0-py2.7.egg\\pkg_resources/*.*' However, in my case the there is no folder inside site-packeges\\setuptools-27* – Jumabek Alikhanov Apr 05 '17 at 23:58

2 Answers2

2

That's because cx_Freeze cannot work with subpackages of packages installed as packed .eggs. A normal Python installation uses pip which always unpacks .eggs, unlike Anaconda.

The corresponding issue: Failed to find module in subpackage in zipped egg · Issue #120 · anthony-tuininga/cx_Freeze. It links to the pull request with the fix:

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:

Replacing all the .eggs you have with unpacked versions with pip install --upgrade as suggested in the other answer is only a temporary solution - until you get another .egg.

ivan_pozdeev
  • 33,874
  • 19
  • 107
  • 152
  • You wrote "A normal Python installation uses pip which always unpacks .egg" I use Python 3.6 which does not unzip the egg. It installed setuptools as zipped egg. After renaming the egg to ".zip" and moving both directories (setuptools and pkg_resources) into the site-packages directory, it works. – guettli Sep 07 '18 at 13:39
  • @guettli see https://stackoverflow.com/questions/27964960/pip-why-sometimes-installed-as-egg-sometimes-installed-as-files – ivan_pozdeev Sep 08 '18 at 01:42
1

I solved the problem by

pip install --upgrade setuptools
pip install --upgrade distribute

which I learned from Ali Akdurak's answer here No module named pkg_resources

Community
  • 1
  • 1
Jumabek Alikhanov
  • 2,305
  • 3
  • 21
  • 21