![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Expert Programmer
|
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' |
|
|
|
|
|
#2 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,799
Rep Power: 5
![]() |
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.
|
|
|
|
|
|
#3 |
|
Expert Programmer
|
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' |
|
|
|
|
|
#4 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,799
Rep Power: 5
![]() |
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. |
|
|
|
|
|
#5 |
|
Expert Programmer
|
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.
|
|
|
|
|
|
#6 |
|
Expert Programmer
|
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.
|
|
|
|
|
|
#7 |
|
Professional Programmer
Join Date: May 2006
Location: Maryland, USA
Posts: 306
Rep Power: 3
![]() |
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.
|
|
|
|
|
|
#8 |
|
Expert Programmer
|
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.
Last edited by titaniumdecoy; Jul 26th, 2006 at 3:05 PM. |
|
|
|
|
|
#9 |
|
Professional Programmer
Join Date: May 2006
Location: Maryland, USA
Posts: 306
Rep Power: 3
![]() |
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.
|
|
|
|
|
|
#10 |
|
Expert Programmer
|
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
) |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| CherryPy with py2exe | Sane | Python | 0 | Feb 5th, 2006 12:01 PM |
| wxGlade and py2exe problem | infinite05 | Python | 0 | Jan 16th, 2006 5:37 PM |
| GUI Problem - py2exe | infinite05 | Python | 7 | Jan 15th, 2006 11:40 PM |
| A py2exe solution | Sane | Python | 4 | Dec 7th, 2005 4:27 PM |