{"id":24121,"library":"nrel-pysam","title":"PySAM","description":"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).","status":"active","version":"7.1.1.post1","language":"python","source_language":"en","source_url":"https://github.com/NREL/pysam","tags":["renewable-energy","system-advisor-model","simulation","solar","wind","battery"],"install":[{"cmd":"pip install nrel-pysam","lang":"bash","label":"PyPI"}],"dependencies":[{"reason":"Numerical arrays for input/output","package":"numpy","optional":false},{"reason":"DataFrames for multi-year outputs","package":"pandas","optional":false},{"reason":"GPU acceleration for certain modules (e.g., photovoltaic)","package":"Nsight","optional":true}],"imports":[{"note":"PySSC is a submodule of PySAM","wrong":"import PySSC","symbol":"PySSC","correct":"import PySAM.PySSC as PySSC"},{"note":"Modules are nested under PySAM package","wrong":"import Pvwattsv8","symbol":"Pvwattsv8","correct":"import PySAM.Pvwattsv8 as Pvwattsv8"},{"note":"Class name matches module name, collision avoided via direct import","wrong":"from PySAM.Battery import Battery as BatteryModel","symbol":"Battery","correct":"from PySAM.Battery import Battery"},{"note":"Must import the class, not just the module","wrong":"import PySAM.CustomGeneration","symbol":"CustomGeneration","correct":"from PySAM.CustomGeneration import CustomGeneration"}],"quickstart":{"code":"import PySAM.Pvwattsv8 as pv\n# Create default system\nsystem_model = pv.default('FlatPlatePV-NoSDK')\n# Modify parameters\nsystem_model.SolarResource.solar_resource_file = 'file.csv'\nsystem_model.execute()\nprint(system_model.Outputs.annual_energy)","lang":"python","description":"Run a default PVWatts simulation and print annual energy. Replace 'file.csv' with a solar resource file."},"warnings":[{"fix":"Use `system_model.Outputs.annual_energy` not `system_model.annual_energy`.","message":"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`.","severity":"gotcha","affected_versions":"all"},{"fix":"Use dot notation for inputs: `module.SolarResource.solar_resource_file = 'path'`.","message":"Calling `module.value('param')` or `module.assign('param', val)` is legacy and fails in v7+. Use property access: `module.SolarResource.solar_resource_file = 'path'`.","severity":"gotcha","affected_versions":">=7.0"},{"fix":"Call `system_model.execute()` after setting inputs.","message":"The `default()` method does not automatically call `execute()`. Many users forget to call `execute()` and then inspect outputs that are still None.","severity":"gotcha","affected_versions":"all"},{"fix":"Migrate to `Pvwattsv8` (note capital P). See migration guide in docs.","message":"In PySAM v7, the `pvwattsv7` module was removed. Code using `import PySAM.pvwattsv7 as pv7` will fail.","severity":"breaking","affected_versions":">=7.0"},{"fix":"Use `Cashloan` instead: `from PySAM.Cashloan import Cashloan`.","message":"The `Singleowner` and `Thirdpartyownership` financial models are deprecated in favor of the unified `Cashloan` model.","severity":"deprecated","affected_versions":">=7.1"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `pip install nrel-pysam` and ensure import uses capital 'P' and 'S': `import PySAM`.","cause":"Package not installed or installed as 'nrel-pysam' but import as 'PySAM' (case-sensitive).","error":"ModuleNotFoundError: No module named 'PySAM'"},{"fix":"Create a module via default() or new() and call execute on that module, not on PySSC.","cause":"Direct call to PySSC object instead of a module (e.g., Pvwattsv8) that has execute().","error":"AttributeError: 'PySSC' object has no attribute 'execute'"},{"fix":"Ensure `system_model.execute()` is called before accessing `system_model.Outputs`.","cause":"Accessing outputs before calling execute().","error":"TypeError: 'NoneType' object is not subscriptable"},{"fix":"Use proper attribute access: `module.SolarResource.solar_resource_file = 'path'`.","cause":"Trying to assign to an input using legacy string-based method like `module.value('solar_resource_file', 'path')` which is no longer supported.","error":"KeyError: 'solar_resource_file'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}