gpt4 book ai didi

python - distutils setup.py install - 'module' 对象不可调用

转载 作者:太空宇宙 更新时间:2023-11-04 01:01:29 25 4
gpt4 key购买 nike

我正在尝试使用特定的 python/numpy 库 rmcgibbo/logsumexp ,但无法安装。这是我按照说明运行 setup.py install 时的跟踪:

$ 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

可能是什么问题?

最佳答案

您正在导入 build_ext 模块,但未指定该模块中的可调用项。您真正想要做的是将 try block 中的内容更改为:

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']

我使用 distutils.command.build_ext 模块对此进行了测试。如果您查看该模块,您会注意到有一个名为 build_ext 的类,因此为了调用“可调用”,您需要按照我的示例中的说明进行导入。我运行了带有代码更改的 setup.py,它成功了。

关于python - distutils setup.py install - 'module' 对象不可调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32628134/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com