Python Spack info.print\u text\u info
Python Spack info.print\u text\u info,python,package,spack,Python,Package,Spack,AttributeError:“str”对象没有属性“build\u system\u class” 我在尝试运行此代码时遇到此错误。有人知道怎么回事吗 import spack.cmd.info import sys pkg = sys.argv[1] spack.cmd.info.print_text_info(pkg) 根据我从你的问题和文件中看到的情况,我假设如下: 您正在尝试使用Spack API() 您正在spack软件包管理器之上构建某种自动化,我怀疑它是一个软件包 您正在使用
AttributeError:“str”对象没有属性“build\u system\u class”
我在尝试运行此代码时遇到此错误。有人知道怎么回事吗
import spack.cmd.info
import sys
pkg = sys.argv[1]
spack.cmd.info.print_text_info(pkg)
根据我从你的问题和文件中看到的情况,我假设如下:
def print_text_info(pkg):
"""Print out a plain text description of a package."""
header = section_title(
'{0}: '
).format(pkg.build_system_class) + pkg.name
color.cprint(header)
如果查看spack.cmd.info
中的info()
方法(实现spack info
命令),您可以看到如何查找名称以获取包实例:
def info(parser, args):
pkg = spack.repo.get(args.package)
print_text_info(pkg)
因此,要将
PacakgeBase
实例传递到print\u text\u info()
,只需导入spack.repo并调用spack.repo.get(name)
。我添加了python标记,因为这是一个纯python问题,其根本原因与spack无关。