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.
That's because cx_Freeze
cannot work with subpackages of packages installed as packed .egg
s. A normal Python installation uses pip
which always unpacks .egg
s, 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 .egg
s 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
.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With