'NoneType' 对象在 OpenLCA 中没有属性 'append'
'NoneType' object has no attribute 'append' with OpenLCA
我正在使用 python 调用软件 OpenLCA 中的函数并在 openLCA 之外处理结果。 openLCA 为进程间通信 (IPC) 提供了基于 JSON-RPC 协议的实现。但是,当我尝试将 Test_Parameter 的值更改为 2000 时出现以下错误: 'NoneType' object has no attribute 'append'.
我正在按照此处提到的确切说明进行操作:https://github.com/GreenDelta/olca-ipc.py
这是我的代码
import olca
import uuid
client = olca.Client(8080)
setup = olca.CalculationSetup()
redef = olca.ParameterRedef()
redef.name = 'Test_Parameter'
redef.value = 2000
setup.parameter_redefs.append(redef)
setup.calculation_type = olca.CalculationType.SIMPLE_CALCULATION
setup.impact_method = client.find(olca.ImpactMethod, 'ReCiPe Midpoint (H)')
setup.product_system = client.find(olca.ProductSystem, 'Test_Process')
setup.amount = 1.0
result = client.calculate(setup)
client.excel_export(result, 'hellotest.xlsx')
client.dispose(result)
任何帮助将不胜感激。
非常感谢
似乎 client.parameter_redefs 被初始化为 None
。我没有看到通过 class 初始化它的定义方法,所以也许你应该直接这样做?
setup = olca.CalculationSetup()
setup.parameter_redefs = []
我正在使用 python 调用软件 OpenLCA 中的函数并在 openLCA 之外处理结果。 openLCA 为进程间通信 (IPC) 提供了基于 JSON-RPC 协议的实现。但是,当我尝试将 Test_Parameter 的值更改为 2000 时出现以下错误: 'NoneType' object has no attribute 'append'.
我正在按照此处提到的确切说明进行操作:https://github.com/GreenDelta/olca-ipc.py
这是我的代码
import olca
import uuid
client = olca.Client(8080)
setup = olca.CalculationSetup()
redef = olca.ParameterRedef()
redef.name = 'Test_Parameter'
redef.value = 2000
setup.parameter_redefs.append(redef)
setup.calculation_type = olca.CalculationType.SIMPLE_CALCULATION
setup.impact_method = client.find(olca.ImpactMethod, 'ReCiPe Midpoint (H)')
setup.product_system = client.find(olca.ProductSystem, 'Test_Process')
setup.amount = 1.0
result = client.calculate(setup)
client.excel_export(result, 'hellotest.xlsx')
client.dispose(result)
任何帮助将不胜感激。
非常感谢
似乎 client.parameter_redefs 被初始化为 None
。我没有看到通过 class 初始化它的定义方法,所以也许你应该直接这样做?
setup = olca.CalculationSetup()
setup.parameter_redefs = []