PySAM
raw JSON → 7.1.1.post1 verified Fri May 01 auth: no python
PySAM is a Python wrapper for the National Renewable Energy Laboratory's System Advisor Model (SAM), enabling simulation of renewable energy systems including PV, wind, battery storage, and CSP. Version 7.1.1.post1 supports SAM version 2024.11.21. Release cadence follows SAM releases (2-3 per year).
pip install nrel-pysam Common errors
error ModuleNotFoundError: No module named 'PySAM' ↓
cause Package not installed or installed as 'nrel-pysam' but import as 'PySAM' (case-sensitive).
fix
Run
pip install nrel-pysam and ensure import uses capital 'P' and 'S': import PySAM. error AttributeError: 'PySSC' object has no attribute 'execute' ↓
cause Direct call to PySSC object instead of a module (e.g., Pvwattsv8) that has execute().
fix
Create a module via default() or new() and call execute on that module, not on PySSC.
error TypeError: 'NoneType' object is not subscriptable ↓
cause Accessing outputs before calling execute().
fix
Ensure
system_model.execute() is called before accessing system_model.Outputs. error KeyError: 'solar_resource_file' ↓
cause Trying to assign to an input using legacy string-based method like `module.value('solar_resource_file', 'path')` which is no longer supported.
fix
Use proper attribute access:
module.SolarResource.solar_resource_file = 'path'. Warnings
gotcha PySAM modules have two layers: the DataSet (inputs) and the Outputs (results). Direct attribute assignment on the module object after `execute()` may override inputs instead of reading outputs; always access outputs via `module.Outputs`. ↓
fix Use `system_model.Outputs.annual_energy` not `system_model.annual_energy`.
gotcha Calling `module.value('param')` or `module.assign('param', val)` is legacy and fails in v7+. Use property access: `module.SolarResource.solar_resource_file = 'path'`. ↓
fix Use dot notation for inputs: `module.SolarResource.solar_resource_file = 'path'`.
gotcha The `default()` method does not automatically call `execute()`. Many users forget to call `execute()` and then inspect outputs that are still None. ↓
fix Call `system_model.execute()` after setting inputs.
breaking In PySAM v7, the `pvwattsv7` module was removed. Code using `import PySAM.pvwattsv7 as pv7` will fail. ↓
fix Migrate to `Pvwattsv8` (note capital P). See migration guide in docs.
deprecated The `Singleowner` and `Thirdpartyownership` financial models are deprecated in favor of the unified `Cashloan` model. ↓
fix Use `Cashloan` instead: `from PySAM.Cashloan import Cashloan`.
Imports
- PySSC wrong
import PySSCcorrectimport PySAM.PySSC as PySSC - Pvwattsv8 wrong
import Pvwattsv8correctimport PySAM.Pvwattsv8 as Pvwattsv8 - Battery wrong
from PySAM.Battery import Battery as BatteryModelcorrectfrom PySAM.Battery import Battery - CustomGeneration wrong
import PySAM.CustomGenerationcorrectfrom PySAM.CustomGeneration import CustomGeneration
Quickstart
import PySAM.Pvwattsv8 as pv
# Create default system
system_model = pv.default('FlatPlatePV-NoSDK')
# Modify parameters
system_model.SolarResource.solar_resource_file = 'file.csv'
system_model.execute()
print(system_model.Outputs.annual_energy)