I have a pretty complicated application I am writing that integrates a lot of modules. Matplotlib was giving some errors until I explicitly included it in the py2exe file. I am getting this error after I compile and try to launch the program and I don't understand what it means. Any help appreciated!
Py2exe compilation file:
from distutils.core import setup
import py2exe, sys, os
sys.argv.append('py2exe')
setup(
options = {
'py2exe': {
'optimize': 2,
'includes' : ["matplotlib.backends.backend_tkagg"],
'packages' : ['matplotlib', 'pytz'],
}
},
windows = [{'script': "MYAPP.py", "icon_resources": [(1, "s.ico")]}],
zipfile = "shared.lib",
Error when launching after compile:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\pint\unit.py", line 756, in load_definitions
with closing(pkg_resources.resource_stream(__name__, file)) as fp:
File "C:\Python34\lib\site-packages\pkg_resources\__init__.py", line 1167, in resource_stream
self, resource_name
File "C:\Python34\lib\site-packages\pkg_resources\__init__.py", line 1602, in get_resource_stream
return io.BytesIO(self.get_resource_string(manager, resource_name))
File "C:\Python34\lib\site-packages\pkg_resources\__init__.py", line 1605, in get_resource_string
return self._get(self._fn(self.module_path, resource_name))
File "C:\Python34\lib\site-packages\pkg_resources\__init__.py", line 1683, in _get
return self.loader.get_data(path)
OSError: [Errno 0] Error: 'pint\\default_en.txt'
I think the problem here lies with py2exe's dealing with txt files. It looks like you're using the pint module and within pint is the file
default_en.txt
(which your compiled app is complaining about). When py2exe compiles pint it ignores the txt files contained within the pint package.The workaround I used was within my script to state:
also, I added the following to my setup.py file for py2exe
from: http://pint.readthedocs.org/en/0.6/index.html
I made
\path\to\
a location within my project and addeddefault_en.txt
andconstants_en.txt
to that folder (copied from pint folder). Then in py2exe I added these files to my data_files.The real solution would be to figure out how to get py2exe include the txt files in module folders but I haven't yet figured that out.