[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

What does Error: 'module' object is not callable Mean?

Cal Who

3/14/2010 6:21:00 PM


The below code produces the error as indicated. But, in
E:\Python26\Lib\site-packages\ffnet\tools I see:
drawffnet.py
drawffnet.pyc
drawffnet.pyo
Is that what it is looking for?

I'm not sure what "not callable" means.
Could it be referencing to "nn" rather than drawffnet?
What should I do to investigate this?

Thanks
from ffnet import ffnet, mlgraph, readdata

....snipped working code here ...

output, regression = nn.test(inputs2, targets2, iprint = 2)

from ffnet.tools import drawffnet
import pylab
drawffnet(nn) #Error: 'module' object is not callable
pylab.show()
except ImportError, e:
print "Cannot make drawffnet plot."


8 Answers

MRAB

3/14/2010 6:46:00 PM

0

Cal Who wrote:
> The below code produces the error as indicated. But, in
> E:\Python26\Lib\site-packages\ffnet\tools I see:
> drawffnet.py
> drawffnet.pyc
> drawffnet.pyo
> Is that what it is looking for?
>
> I'm not sure what "not callable" means.
> Could it be referencing to "nn" rather than drawffnet?
> What should I do to investigate this?
>
> Thanks
> from ffnet import ffnet, mlgraph, readdata
>
> ...snipped working code here ...
>
> output, regression = nn.test(inputs2, targets2, iprint = 2)
>
> from ffnet.tools import drawffnet
> import pylab
> drawffnet(nn) #Error: 'module' object is not callable
> pylab.show()
> except ImportError, e:
> print "Cannot make drawffnet plot."
>
You're importing the module 'drawffnet' and then trying to call it in:

drawffnet(nn)

but, as the traceback says, modules can't be called.

I had a quick look at the documentation and it looks like you should be
calling a function called 'drawffnet' that's defined in the module
called 'drawffnet'. Try doing:

from ffnet.tools.drawffnet import drawffnet

instead.

Terry Reedy

3/14/2010 6:48:00 PM

0

On 3/14/2010 2:20 PM, Cal Who wrote:
>
> The below code produces the error as indicated. But, in
> E:\Python26\Lib\site-packages\ffnet\tools I see:
> drawffnet.py

drawffnet is a module initialized from drawffnet.py (or either of the below)

> drawffnet.pyc
> drawffnet.pyo
> Is that what it is looking for?
>
> I'm not sure what "not callable" means.
> Could it be referencing to "nn" rather than drawffnet?
> What should I do to investigate this?
>
> Thanks
> from ffnet import ffnet, mlgraph, readdata
>
> ...snipped working code here ...
>
> output, regression = nn.test(inputs2, targets2, iprint = 2)
>
> from ffnet.tools import drawffnet

here you create drawffnet from one of the files.

> import pylab
> drawffnet(nn) #Error: 'module' object is not callable

This is an attempt to call the module as if it were a functions, which
it is not. You probably want to call a function within the module.


> pylab.show()
> except ImportError, e:
> print "Cannot make drawffnet plot."
>
>


Cal Who

3/14/2010 8:59:00 PM

0

Thanks for the replies.
That fixed it but produced another problem.

There are two plotting routines below.
Either one will work without error.
But the combo produces:
The exception unknown software exception (0x40000015) occurred in the
application at location 0x1e05b62a.
in a dialog box and the following in the console
Fatal Python error: PyEval_RestoreThread: NULL tstate


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

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

Do you see what isa wrong?

Second question: Is it common to group all the "from" statements at the top
of the program
or to put them by the relavent code as I have here?

Thanks a lot


try:

#Or we can use the two commented statements

#from ffnet.tools import drawffnet

from ffnet.tools.drawffnet import drawffnet

import pylab

#drawffnet.drawffnet(nn)

drawffnet(nn)

pylab.show()

except ImportError, e:

print "Cannot make drawffnet plot.\n%s" % e


?

?

# Plot adapted from

# http://ffnet.sourceforge.net/examples/...

# Make plot if matplotlib is avialble

try:

from pylab import *

plot( targets2, 'b--' )

plot( output, 'k-' )

legend(('target', 'output'))

xlabel('pattern'); ylabel('benign or malignant')

title('Outputs vs. target of trained network.')

grid(True)

show()

except ImportError, e:

print "Cannot make plots. For plotting install matplotlib.\n%s" % e



?

?


Cal Who

3/14/2010 9:01:00 PM

0


"MRAB" <python@mrabarnett.plus.com> wrote in message
news:mailman.745.1268592389.23598.python-list@python.org...
> Cal Who wrote:
>> The below code produces the error as indicated. But, in
>> E:\Python26\Lib\site-packages\ffnet\tools I see:
>> drawffnet.py
>> drawffnet.pyc
>> drawffnet.pyo
>> Is that what it is looking for?
>>
>> I'm not sure what "not callable" means.
>> Could it be referencing to "nn" rather than drawffnet?
>> What should I do to investigate this?
>>
>> Thanks
>> from ffnet import ffnet, mlgraph, readdata
>>
>> ...snipped working code here ...
>>
>> output, regression = nn.test(inputs2, targets2, iprint = 2)
>>
>> from ffnet.tools import drawffnet
>> import pylab
>> drawffnet(nn) #Error: 'module' object is not callable
>> pylab.show()
>> except ImportError, e:
>> print "Cannot make drawffnet plot."
> You're importing the module 'drawffnet' and then trying to call it in:
>
> drawffnet(nn)
>
> but, as the traceback says, modules can't be called.
>
> I had a quick look at the documentation and it looks like you should be
> calling a function called 'drawffnet' that's defined in the module
> called 'drawffnet'. Try doing:
>
> from ffnet.tools.drawffnet import drawffnet
>
> instead.

Thanks, Works great - please see my other post


Cal Who

3/14/2010 9:02:00 PM

0


"Terry Reedy" <tjreedy@udel.edu> wrote in message
news:mailman.746.1268592481.23598.python-list@python.org...
> On 3/14/2010 2:20 PM, Cal Who wrote:
>>
>> The below code produces the error as indicated. But, in
>> E:\Python26\Lib\site-packages\ffnet\tools I see:
>> drawffnet.py
>
> drawffnet is a module initialized from drawffnet.py (or either of the
> below)
>
>> drawffnet.pyc
>> drawffnet.pyo
>> Is that what it is looking for?
>>
>> I'm not sure what "not callable" means.
>> Could it be referencing to "nn" rather than drawffnet?
>> What should I do to investigate this?
>>
>> Thanks
>> from ffnet import ffnet, mlgraph, readdata
>>
>> ...snipped working code here ...
>>
>> output, regression = nn.test(inputs2, targets2, iprint = 2)
>>
>> from ffnet.tools import drawffnet
>
> here you create drawffnet from one of the files.
>
>> import pylab
>> drawffnet(nn) #Error: 'module' object is not callable
>
> This is an attempt to call the module as if it were a functions, which it
> is not. You probably want to call a function within the module.
Exactly. Thanks it works now. Please see my other post.

>
>
>> pylab.show()
>> except ImportError, e:
>> print "Cannot make drawffnet plot."
>>
>>
>
>


Chris Rebert

3/14/2010 9:18:00 PM

0

On Sun, Mar 14, 2010 at 12:58 PM, Cal Who <CalWhoNOSPAM@roadrunner.com> wrote:
<snip>
> Second question: Is it common to group all the "from" statements at the top
> of the program
> or to put them by the relavent code as I have here?

The former.

Cheers,
Chris
--
http://blog.re...

Cal Who

3/14/2010 10:50:00 PM

0

I cleaned up the code by moving all the imports to the top.
There are two plotting routines shown below.
Either one will work without error.
But when I include both, running produces:
The exception unknown software exception (0x40000015) occurred in the
application at location 0x1e05b62a.
In a dialog box and the following in the console:
Fatal Python error: PyEval_RestoreThread: NULL tstate
This application has requested the Runtime to terminate it in an unusual
way.
Please contact the application's support team for more information.

Do you see what is wrong?

Thanks a lot

from pylab import plot, legend, title, grid, show, xlabel, ylabel
....snip....

#FIRST PLOT
plot( targets2, 'b--' )
plot( output, 'k-' )
legend(('target', 'output'))
xlabel('pattern'); ylabel('benign or malignant')
title('Outputs vs. target of trained network.')
grid(True)
show()

#SECOND PLOT
drawffnet(nn)
show()


Cal Who

3/14/2010 11:37:00 PM

0

I found it. Had to use "figure" to create a new figure!


" Cal Who" <CalWhoNOSPAM@roadrunner.com> wrote in message
news:hnjp6f$l4$1@news.eternal-september.org...
>I cleaned up the code by moving all the imports to the top.
> There are two plotting routines shown below.
> Either one will work without error.
> But when I include both, running produces:
> The exception unknown software exception (0x40000015) occurred in the
> application at location 0x1e05b62a.
> In a dialog box and the following in the console:
> Fatal Python error: PyEval_RestoreThread: NULL tstate
> This application has requested the Runtime to terminate it in an unusual
> way.
> Please contact the application's support team for more information.
>
> Do you see what is wrong?
>
> Thanks a lot
>
> from pylab import plot, legend, title, grid, show, xlabel, ylabel
> ...snip....
>
> #FIRST PLOT
> plot( targets2, 'b--' )
> plot( output, 'k-' )
> legend(('target', 'output'))
> xlabel('pattern'); ylabel('benign or malignant')
> title('Outputs vs. target of trained network.')
> grid(True)
> show()
>
> #SECOND PLOT
> drawffnet(nn)
> show()
>