akxlr
akxlr

Reputation: 1182

distutils setup.py install - 'module' object is not callable

I am trying to use a particular python/numpy library rmcgibbo/logsumexp, but can't get it to install. Here is the trace when I run setup.py install as per the instructions:

$ python setup.py install
running install
running build
running build_ext
Traceback (most recent call last):
  File "setup.py", line 26, in <module>
    ext_modules = [ext]
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/install.py", line 573, in run
    self.run_command('build')
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build.py", line 127, in run
    self.run_command(cmd_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 970, in run_command
    cmd_obj = self.get_command_obj(command)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 846, in get_command_obj
    cmd_obj = self.command_obj[command] = klass(self)
TypeError: 'module' object is not callable

Contents of setup.py

What could the problem be?

Upvotes: 2

Views: 726

Answers (1)

idjaw
idjaw

Reputation: 26560

You are importing the build_ext module, but not specifying what the callable is in that module. What you actually want do is change what you have in your try block to this:

try:
    from Cython.Distutils.build_ext import build_ext
    src = ['sselogsumexp.pyx', 'src/logsumexp.c']
except ImportError:
    from distutils.command.build_ext import build_ext
    src = ['sselogsumexp.c', 'src/logsumexp.c']

I tested this with the distutils.command.build_ext module. If you look in that module you will notice there is a class called build_ext, so in order to call the 'callable', you will need to import as specified in my example. I ran the setup.py with the code change and it worked.

Upvotes: 3

Related Questions