1.3.0 and py2exe regression

we have some code that was working fine with matplotlib 1.2.1 using:

from mpl_toolkits.axes_grid import make_axes_locatable, axes_size

now trying to freeze with py2exe (both 0.6.9 and Christoph Gohlke's
0.6.10dev)
results in ImportError: No module named mpl_toolkits

when preparing the actual executable.
running "from mpl_toolkits.axes_grid import make_axes_locatable, axes_size"
itself in python works fine.

I've built a machine afresh and am getting this. Also, it seems to build
fine on win amd64 - but as that is my main development machine, there may be
some polution there

options={'py2exe': {'packages' : ['matplotlib', 'mpl_toolkits', ...

I've tried various different permutations of the above in includes with no
success.
Can anybody suggest why this is failing in 1.3.0 when it is working in 1.2.1
?

Regards,
RuiDC

···

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/1-3-0-and-py2exe-regression-tp41723.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

I have little to no experience with py2exe, so I don't know how much I can help there.

However, between 1.2.1 and 1.3.0, mpl_toolkits was changed to a "namespace" package, which allowed basemap to install into it despite it coming from matplotlib (and being installed with setuptools). I don't know if that has any bearing on py2exe.

Mike

···

On 08/06/2013 07:19 AM, ruidc wrote:

we have some code that was working fine with matplotlib 1.2.1 using:

from mpl_toolkits.axes_grid import make_axes_locatable, axes_size

now trying to freeze with py2exe (both 0.6.9 and Christoph Gohlke's
0.6.10dev)
results in ImportError: No module named mpl_toolkits

when preparing the actual executable.
running "from mpl_toolkits.axes_grid import make_axes_locatable, axes_size"
itself in python works fine.

I've built a machine afresh and am getting this. Also, it seems to build
fine on win amd64 - but as that is my main development machine, there may be
some polution there

options={'py2exe': {'packages' : ['matplotlib', 'mpl_toolkits', ...

I've tried various different permutations of the above in includes with no
success.
Can anybody suggest why this is failing in 1.3.0 when it is working in 1.2.1
?

Regards,
RuiDC

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/1-3-0-and-py2exe-regression-tp41723.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent
caught up. So what steps can you take to put your SQL databases under
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Thanks, for the moment, it seems that removing the 'mpl_toolkits' from
packages makes it work.
Also, with the removal of dateutil from the binary, and installation of
dateutil from source pulling in six via easy_install/pip meant it also was
not found by py2exe. I got around this by using Christoph Gohlke's binary
installer of six. HTH someone else.

Regards,
RuiDC

···

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/1-3-0-and-py2exe-regression-tp41723p41727.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

No, this is still coming back to haunt me. I can't figure out how to be able
to package this via py2exe now:

I am running the command:

python setup2.py py2exe

via python 2.7.5 and matplotlib 1.3.0 and py2exe 0.6.9 and 0.6.10dev

I have read http://www.py2exe.org/index.cgi/ExeWithEggs and tried to
implement the suggestions for handling the mpl_toolkits having become a
namespace package.

Can anyone suggest what I need to make this work?:

test_mpl.py is:

···

--------------
from mpl_toolkits.axes_grid1 import make_axes_locatable, axes_size

if __name__ == '__main__':
    print make_axes_locatable, axes_size

--------------
setup2.py is:
--------------
import py2exe
import distutils.sysconfig
from distutils.core import setup

import modulefinder
import matplotlib
import mpl_toolkits.axes_grid1
__import__('pkg_resources').declare_namespace("mpl_toolkits")
__import__('pkg_resources').declare_namespace("mpl_toolkits.axes_grid1")
modulefinder.AddPackagePath("mpl_toolkits", matplotlib.__path__[0])
modulefinder.AddPackagePath("mpl_toolkits.axes_grid1",
mpl_toolkits.axes_grid1.__path__[0])

options={'py2exe': {'packages' : ['matplotlib', 'mpl_toolkits.axes_grid1',
'pylab', 'zmq'],
                    'includes': ['zmq', 'six'],
                    'excludes': ['_gdk', '_gtk', '_gtkagg', '_tkagg',
'PyQt4.uic.port_v3', 'Tkconstants', 'Tkinter', 'tcl'],
                    'dll_excludes': ['libgdk-win32-2.0-0.dll',
                                     'libgdk_pixbuf-2.0-0.dll',
                                     'libgobject-2.0-0.dll',
                                     'tcl85.dll',
                                     'tk85.dll'],
                    'skip_archive': True },}

setup(console=['test_mpl.py'], options=options)

--------------
output is:
--------------

running py2exe
*** searching for required modules ***
Traceback (most recent call last):
  File "setup2.py", line 23, in <module>
    setup(console=['test_mpl.py'], options=options)
  File "C:\Python27\lib\distutils\core.py", line 152, in setup
    dist.run_commands()
  File "C:\Python27\lib\distutils\dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "C:\Python27\lib\site-packages\py2exe\build_exe.py", line 243, in run
    self._run()
  File "C:\Python27\lib\site-packages\py2exe\build_exe.py", line 296, in
_run
    self.find_needed_modules(mf, required_files, required_modules)
  File "C:\Python27\lib\site-packages\py2exe\build_exe.py", line 1308, in
find_needed_modules
    mf.import_hook(f)
  File "C:\Python27\lib\site-packages\py2exe\mf.py", line 719, in
import_hook
    return Base.import_hook(self,name,caller,fromlist,level)
  File "C:\Python27\lib\site-packages\py2exe\mf.py", line 136, in
import_hook
    q, tail = self.find_head_package(parent, name)
  File "C:\Python27\lib\site-packages\py2exe\mf.py", line 204, in
find_head_package
    raise ImportError, "No module named " + qname
ImportError: No module named mpl_toolkits

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/1-3-0-and-py2exe-regression-tp41723p41961.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

PyInstaller 2.0 also has exactly the same error.
cx_Freeze unfortunately has problems with some tricks in numpy 1.7.x.

···

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/1-3-0-and-py2exe-regression-tp41723p41972.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

There is a quite simple workaround to this problem. Find the directory from
which mpl_tools is imported and simply add an empty text file named
"__init__.py" in that directory. py2exe will now find and include this
module without any special imports needed in the setup file.

You can find the mpl_tools directory by typing the following in a python
console:
import importlib
importlib.import_module('mpl_toolkits').__path__

I found the solution here http://stackoverflow.com/a/11632115/2166823 and it
seems to apply to namespace packages in general.

I posted this solution to Stack Overflow as well
http://stackoverflow.com/a/19848039/2166823.

···

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/1-3-0-and-py2exe-regression-tp41723p42472.html
Sent from the matplotlib - users mailing list archive at Nabble.com.