Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Python (http://www.programmingforums.org/forum43.html)
-   -   py2exe with matplotlib (http://www.programmingforums.org/showthread.php?t=10845)

titaniumdecoy Jul 25th, 2006 6:32 PM

py2exe with matplotlib
 
I'm trying to compile my Python program (just 2 files) with py2exe. It uses a number of modules, including wx, matplotlib, and numeric. After some tweaking, I got py2exe to produce the executable, however, I get the following error message whenever I run it:

:

import core -> failed: No module named _internal
import lib -> failed: 'module' object has no attribute '_ARRAY_API'
import linalg -> failed: 'module' object has no attribute '_ARRAY_API'
import dft -> failed: 'module' object has no attribute '_ARRAY_API'
import random -> failed: 'module' object has no attribute 'dtype'
Traceback (most recent call last):
  File "dataview_gui.py", line 9, in ?
  File "datareader.pyc", line 7, in ?
   
  File "pylab.pyc", line 1, in ?
    mò
  File "matplotlib\pylab.pyc", line 196, in ?
    roots    - the roots of the polynomial coefficients in p
  File "matplotlib\cm.pyc", line 5, in ?
   
  File "matplotlib\colors.pyc", line 33, in ?
    For a greater range of colors, you have two options.  You can specify
  File "matplotlib\numerix\__init__.pyc", line 67, in ?
    %(specific)s could not be satisfied, or because the build flag for
  File "numpy\__init__.pyc", line 49, in ?
    
  File "numpy\add_newdocs.pyc", line 2, in ?
    gkDc
  File "numpy\lib\__init__.pyc", line 5, in ?
   
  File "numpy\lib\type_check.pyc", line 8, in ?
   
  File "numpy\core\__init__.pyc", line 6, in ?
   
  File "numpy\core\umath.pyc", line 12, in ?
   
  File "numpy\core\umath.pyc", line 10, in __load
   
AttributeError: 'module' object has no attribute '_ARRAY_API'

Help!

Sane Jul 25th, 2006 10:00 PM

When you were compiling, did you mention both files inside the setup file? If you only specify one, I don't think it searches for any imports in the second file, even if the first imports the second.

titaniumdecoy Jul 26th, 2006 12:29 PM

Thanks, Sane, but I'm not sure what you mean (ie, how do you specify a second source file?). I'm pretty sure that's not the problem though, I think it has something to do with importing the matplotlib/numeric module(s). I keep getting this _ARRAY_API error.

I've tried reinstalling matplotlib and numeric, and even installing scipy; however, nothing seems to make any difference. I really need this to work, so any help would be greatly appreciated!

:

Traceback (most recent call last):
  File "dataview_gui.py", line 9, in ?
  File "datareader.pyc", line 7, in ?
   
  File "pylab.pyc", line 1, in ?
    mò
  File "matplotlib\pylab.pyc", line 196, in ?
    roots    - the roots of the polynomial coefficients in p
  File "matplotlib\cm.pyc", line 5, in ?
   
  File "matplotlib\colors.pyc", line 33, in ?
    For a greater range of colors, you have two options.  You can specify
  File "matplotlib\numerix\__init__.pyc", line 70, in ?
    %(which)s and then re-install matplotlib. Otherwise, the following
  File "numpy\__init__.pyc", line 35, in ?
    testing  --- Scipy testing tools
  File "numpy\core\__init__.pyc", line 6, in ?
   
  File "numpy\core\umath.pyc", line 12, in ?
   
  File "numpy\core\umath.pyc", line 10, in __load
   
AttributeError: 'module' object has no attribute '_ARRAY_API'


Sane Jul 26th, 2006 1:20 PM

Well, you said there was a second file. I assumed you were importing those modules indirectly through the second file. And if you read my last post, you would see why that could be causing the error you currently see.

To specify the second file, I believe you make it another item in the console key. Check the py2exe model setup scripts.

titaniumdecoy Jul 26th, 2006 1:42 PM

The docs say it looks for everything it needs, including modules in other files, etc. I tried it, and I just got two executables, neither of which work. Thanks anyway.

titaniumdecoy Jul 26th, 2006 2:13 PM

I may have to resort to not using matplotlib (which requires numeric). Does anyone know of an alternative free plotting package to matplotlib? I need only basic plotting capabilities.

Game_Ender Jul 26th, 2006 2:31 PM

Have you gotten a pure wxPython program to be packaged with py2exe (nothing is really complied)? After you got that out of way look up the docs of py2exe for how modules that have native code (ie dll files) are used with py2exe. It looks as if numeric can't find the C based dll that it needs in order to run.

titaniumdecoy Jul 26th, 2006 2:48 PM

You might be right; I was excluding a bunch of dll files that I didn't want to bother downloading. However, I downloaded, installed, and included all the dll files but one, and sadly I get the same error. If you're right, the problem could be that I didn't install the one dll file it needed (unlikely, but possible?), which is wxmsw26uh_vc.dll. I've searched all over for this file but it seems to be impossible to find. If anyone could help me out here, it would be great.

Game_Ender Jul 26th, 2006 3:48 PM

You should also look into the wxPython forums on how to package wxPython with py2exe, they have some instructions. From the looks of that dll it is wxWidgets 2.6, compiled for windows with unicode enabled and the VC++ compiler. I don't know what the h is. You must have the wxWidgets dll if you want wxPython to work.

titaniumdecoy Jul 26th, 2006 3:55 PM

I commented out the parts of my code that use matplotlib, and py2exe works fine. So the problem is with matplotlib, not wxPython. I'm still not sure what to do.

This is the setup.py file I'm using:

:

# setup.py
from distutils.core import setup
import py2exe

from distutils.filelist import findall
import os
import matplotlib
matplotlibdatadir = matplotlib.get_data_path()
matplotlibdata = findall(matplotlibdatadir)
matplotlibdata_files = []
for f in matplotlibdata:
    dirname = os.path.join('matplotlibdata', f[len(matplotlibdatadir)+1:])
    matplotlibdata_files.append((os.path.split(dirname)[0], [f]))

setup(
    windows=["dataview_gui.py"],
    options={
            'py2exe': {
                        'packages' : ['matplotlib'],
                        'dll_excludes': ['wxmsw26uh_vc.dll'],
                      },
            },
    data_files=matplotlibdata_files
)



All times are GMT -5. The time now is 9:46 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC