Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 25th, 2006, 6:32 PM   #1
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 837
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
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!
titaniumdecoy is offline   Reply With Quote
Old Jul 25th, 2006, 10:00 PM   #2
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,799
Rep Power: 5 Sane will become famous soon enough
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.
Sane is offline   Reply With Quote
Old Jul 26th, 2006, 12:29 PM   #3
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 837
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
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'
titaniumdecoy is offline   Reply With Quote
Old Jul 26th, 2006, 1:20 PM   #4
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,799
Rep Power: 5 Sane will become famous soon enough
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.
Sane is offline   Reply With Quote
Old Jul 26th, 2006, 1:42 PM   #5
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 837
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
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 is offline   Reply With Quote
Old Jul 26th, 2006, 2:13 PM   #6
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 837
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
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.
titaniumdecoy is offline   Reply With Quote
Old Jul 26th, 2006, 2:31 PM   #7
Game_Ender
Professional Programmer
 
Game_Ender's Avatar
 
Join Date: May 2006
Location: Maryland, USA
Posts: 306
Rep Power: 3 Game_Ender is on a distinguished road
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.
Game_Ender is offline   Reply With Quote
Old Jul 26th, 2006, 2:48 PM   #8
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 837
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
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.
titaniumdecoy is offline   Reply With Quote
Old Jul 26th, 2006, 3:48 PM   #9
Game_Ender
Professional Programmer
 
Game_Ender's Avatar
 
Join Date: May 2006
Location: Maryland, USA
Posts: 306
Rep Power: 3 Game_Ender is on a distinguished road
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.
Game_Ender is offline   Reply With Quote
Old Jul 26th, 2006, 3:55 PM   #10
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 837
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
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
)
titaniumdecoy is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:23 PM.

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