Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cx_Freeze cannot find pkg_resources/*.*'

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.

like image 938
Yiftach Avatar asked Oct 17 '22 16:10

Yiftach


2 Answers

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.

like image 185
ivan_pozdeev Avatar answered Oct 21 '22 05:10

ivan_pozdeev


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

like image 37
Jumabek Alikhanov Avatar answered Oct 21 '22 04:10

Jumabek Alikhanov