py2exe wxpython wxmpl - how do you force the loading of numarray?

Hi,
Still tryin' to freeze my wxmpl matplotlib application.... sigh.

This is wxpython + wxmpl + matplotlib. This has turned into one hell of a fight - BUT I think I am about to win. You have to keep the faith :-}

Name the py2exe issue with freezing matplotlib / wxmpl and I have been there fought that. I have slayed many dragons...

I now have a problem that has been asked before on this list. I have tried the answer that was offered- it didnt help. I think I am in a postion to ask a simple solid question...

When I run my application I see this....

Fatal Python error: Call to API function without first calling import_libnumarray() in Src\_convmodule.c

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

I added import numarray all over the place... a previous post suggested that maybe Wxpython was calling numarray before I was... no I dont think wxpython and numarray ever need each other.

To help prove this I changed my application to this: (a boa app - so this code occurs early in execution but not before wxpython has been used...

    def __init__(self, parent):

        import numarray
        import numarray.numarrayall # desperate attempt to stop error api call without first calling import_libnumarray
           self._init_ctrls(parent) # init wxpython controls
         print numarray.__version__

and bang my application no longer runs. If I comment out this print line, the application runs perfectly except when you click the button to draw the graph. Then you get the same error message as above.

BTW in the development environments - application works fine - and that's because the development environs are loading the modules from the python installation - is my call...

In my library file you can see that numarray is definitely included - it's there.

So my question is:
Q: How do you force the loading (not the inclusion) of the nummary module? Or how do you get import_libnumarray to run?

Can some one tell me more about the mechanism python uses to load the modules.. What triggers the load call? Where?

I know I am close. Rest of the application is 95% finished. Customer loves it. 2 week delay coz I cant freeze the @#$@$%@ thing.

BTW kudos to py2exe developers and maintainers - as I learn more about the challenges in identifying the modules and the packaging of them etc - I appreciate it. This is not a sucking up effort to get an answer - but if it helps.... :-}

thanks

PS I have cross posted this to matploblib and py2exe lists - I am desperate!

···

--
Tim Burgess
IT Consultant
RedHat Certified Engineer
TBITC Pty Ltd
Professional Computer Support for Business
timb@...847...
Mobile 0422 942 972
Office 85 662 016
http://www.tbitc.com

Suddenly I feel less alone.

.

I’m engaged in exactly the same process right now,
I’ve tried moving the whole of numarray into the dist a dir out of
sheer desperation…but no go- my traceback looks like this…

Traceback (most recent call last):

Traceback (most recent call last):

File “HacGui.py”, line 21, in ?

File “activity.pyc”, line 17, in ?

File “matplotlib\axes.pyc”, line 5, in ?

File
“C:\DOCUME~1\ROBMAR~1\REPO\Hydra2\hydra\admin\client\HAC\build\dist_init_.pyc”,
line 95, in ?

ImportError: No module named random_array

As soon as I remove numarray fropm the dist dir this resolves to

Fatal Python error: Call to API function without first calling
import_libnumarray() in Src_convmodule.c

I came across a post yesterday

that suggests that it’s possible to ‘force’ the whole of numarray into an app. I’d like to know how though
(‘.’,
glob.glob(r’C:\PROGRA~1\Python24\share\MATPLO~1\matplotlibrc’)),
(‘.’,
glob.glob(r’C:\PROGRA~1\Python24\Lib\SITE-P~1\numarray*.py’)), …seems to take care of an earlier error ( can’t find matplotlibrc
file) You have my complete empathy on this problem. In the event I come up
with some sort of magic bullet, I’ll mail you ASAP.
Have fun Rob M.

Tim Burgess wrote:

···

http://aspn.activestate.com/ASPN/Mail/Message/numpy-discussion/2852995
__Russell E. Owen wrote:

If I convert my python code to an
application (Windows via py2exe or Mac > via bundlebuilder) it fails with the
following error:

Fatal Python error: Call to API function without first calling > import_libnumarray() in Src/_convmodule.c

This currently (1.3.3) happens when a numarray API function is
called before the API is successfully initialized. Although the message
was intended as an aid to extension writers, in this case numarray is
failing to import altogether. At one point numarray had a fatal error
for import failures but I removed it at someone’s request. I’ve
restored it because I think it’s most commonly fatal anyway and
removing the message just obfuscated the problem. The non-fatal
behavior is now in the _import_libnumarray() macro.

I can force all of numarray into
the application, which avoids the >

This is what you need to do. It should be possible to factor out (or
not explicitly list) numarray’s Packages, but core numarray is not
meant to be distributed in pieces. The many type-specific extensions
were only added to work around a compiler problem, not to lighten
binary distributions.
.__

:slight_smile:

Hi,

Still tryin’ to freeze my wxmpl matplotlib application… sigh.

This is wxpython + wxmpl + matplotlib. This has turned into one hell of
a fight - BUT I think I am about to win. You have to keep the faith :-}

Name the py2exe issue with freezing matplotlib / wxmpl and I have been
there fought that. I have slayed many dragons…

I now have a problem that has been asked before on this list. I have
tried the answer that was offered- it didnt help. I think I am in a
postion to ask a simple solid question…

When I run my application I see this…

Fatal Python error: Call to API function without first calling
import_libnumarray() in Src_convmodule.c

This application has requested the Runtime to terminate it in an
unusual way.

Please contact the application’s support team for more information.

I added import numarray all over the place… a previous post suggested
that maybe Wxpython was calling numarray before I was… no I dont
think wxpython and numarray ever need each other.

To help prove this I changed my application to this: (a boa app - so
this code occurs early in execution but not before wxpython has been
used…

def init(self, parent):

   import numarray


   import numarray.numarrayall # desperate attempt to stop error

api call without first calling import_libnumarray

     self._init_ctrls(parent)   # init wxpython controls




   print numarray.__version__

and bang my application no longer runs. If I comment out this print
line, the application runs perfectly except when you click the button
to draw the graph. Then you get the same error message as above.

BTW in the development environments - application works fine - and
that’s because the development environs are loading the modules from
the python installation - is my call…

In my library file you can see that numarray is definitely included -
it’s there.

So my question is:

Q: How do you force the loading (not the inclusion) of the nummary
module? Or how do you get import_libnumarray to run?

Can some one tell me more about the mechanism python uses to load the
modules… What triggers the load call? Where?

I know I am close. Rest of the application is 95% finished. Customer
loves it. 2 week delay coz I cant freeze the @#@%@ thing.

BTW kudos to py2exe developers and maintainers - as I learn more about
the challenges in identifying the modules and the packaging of them etc

  • I appreciate it. This is not a sucking up effort to get an answer -
    but if it helps… :-}

thanks

PS I have cross posted this to matploblib and py2exe lists - I am
desperate!

       -- O__
_/`.\
`=( '

Tim Burgess wrote:

Hi,
Still tryin' to freeze my wxmpl matplotlib application.... sigh.

This is wxpython + wxmpl + matplotlib. This has turned into one hell of a fight - BUT I think I am about to win. You have to keep the faith :-}

Name the py2exe issue with freezing matplotlib / wxmpl and I have been there fought that. I have slayed many dragons...

I now have a problem that has been asked before on this list. I have tried the answer that was offered- it didnt help. I think I am in a postion to ask a simple solid question...

When I run my application I see this....

Fatal Python error: Call to API function without first calling import_libnumarray() in Src\_convmodule.c

Either an extension in your application forgot to call import_libnumarray() or the numarray distributed as part of your application is incomplete or broken and the import failed. numarray CVS now makes a better report of which is true.

I added import numarray all over the place... a previous post suggested that maybe Wxpython was calling numarray before I was... no I dont think wxpython and numarray ever need each other.

To help prove this I changed my application to this: (a boa app - so this code occurs early in execution but not before wxpython has been used...

   def __init__(self, parent):

       import numarray
       import numarray.numarrayall # desperate attempt to stop error api call without first calling import_libnumarray
         self._init_ctrls(parent) # init wxpython controls

       print numarray.__version__

and bang my application no longer runs. If I comment out this print line, the application runs perfectly except when you click the button to draw the graph. Then you get the same error message as above.

BTW in the development environments - application works fine - and that's because the development environs are loading the modules from the python installation - is my call...

My guess is that in the development environments numarray is already correctly installed.

In my library file you can see that numarray is definitely included - it's there.

So my question is:
Q: How do you force the loading (not the inclusion) of the nummary module?

I may not understand you, but when numarray is all there, "import numarray" should work just like for any other Python package. I think your problem is that numarray is not being included correctly in your installer because it's extension dependencies are hard for py2exe to detect correctly. I believe this is fixed now in numarray CVS.

Or how do you get import_libnumarray to run?

import_libnumarray() is something an extension writer must explicitly call in their extension init() if they want to use the numarray API.

Can some one tell me more about the mechanism python uses to load the modules.. What triggers the load call? Where?

I know I am close. Rest of the application is 95% finished. Customer loves it. 2 week delay coz I cant freeze the @#@%@ thing.

Try using numarray CVS to generate your installer. Last week someone had a similar issue with this and I added code to numarray.__init__ to explicitly import all numarray's core extensions. That user reported that the extra "hints" in numarray.__init__ helped py2exe detect the necessary numarray extension set correctly, numarray was thus installed correctly, and the installer worked.

Regards,
Todd

Fatal Python error: Call to API function without first calling import_libnumarray() in Src\_convmodule.c

It looks like someone who was having the same problem got some reasonable advice from the numpy-discussion mailing list:

  ActiveState Community - Boosting coder and team productivity with ready-to-use open source languages and tools.

From the posting, it sounds like you need to figure out how to make py2exe include all of numarray. I would start out by py2exe-ing a short test script that just imports numarray and makes an array, then moving on to your full application after you get that working.

I added import numarray all over the place... a previous post suggested that maybe Wxpython was calling numarray before I was... no I dont think wxpython and numarray ever need each other.

That's not going to fix the problem: the error is referring to a C macro/function called `import_numarray' that is apparently supposed to be called while numarray is initializing itself. In the email linked to above, Todd Miller says that this is indicative of numarray being incompletely included by py2exe.

In my library file you can see that numarray is definitely included - it's there.

All of it? I think you should should probably check that the numarray package bundled in the py2exe zip file is identical to the one in site-packages (i.e. the number of files is the same).

Ken

···

On Oct 19, 2005, at 3:08 AM, Tim Burgess wrote: